mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add EABase, EAThread and DirtySDK to R5sdk
DirtySDK (EA's Dirty Sockets library) will be used for the LiveAPI implementation, and depends on: EABase, EAThread.
This commit is contained in:
parent
57dc081d4a
commit
d24d4a52dd
@ -580,6 +580,123 @@ Mbed TLS & l8w8jwt
|
||||
// limitations under the License.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
************************************************************************************
|
||||
DirtySDK (EA WebKit)
|
||||
************************************************************************************
|
||||
|
||||
// Copyright (C) 1999-2007, 2009-2010, 2012-2013 Electronic Arts Inc
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
************************************************************************************
|
||||
EAThread (EA WebKit)
|
||||
************************************************************************************
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Copyright (C) 2017 Electronic Arts Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
// Additional licenses also apply to this software package as detailed below.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
// Copyright (c) 2015 Jeff Preshing
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgement in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//--------------------------------------------------------------------------
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
************************************************************************************
|
||||
EABase (EA WebKit)
|
||||
************************************************************************************
|
||||
|
||||
// Copyright (C) 2002-2013 Electronic Arts Inc
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
************************************************************************************
|
||||
Zstandard
|
||||
************************************************************************************
|
||||
|
@ -46,6 +46,10 @@ add_subdirectory( thirdparty/cppnet )
|
||||
set( FOLDER_CONTEXT "Thirdparty/Networking" )
|
||||
add_subdirectory( thirdparty/protobuf )
|
||||
add_subdirectory( thirdparty/curl )
|
||||
add_subdirectory( thirdparty/dirtysdk )
|
||||
|
||||
set( FOLDER_CONTEXT "Thirdparty/Threading" )
|
||||
add_subdirectory( thirdparty/ea/EAThread )
|
||||
|
||||
set( FOLDER_CONTEXT "Tools" )
|
||||
add_subdirectory( sdklauncher )
|
||||
|
191
src/thirdparty/dirtysdk/CMakeLists.txt
vendored
Normal file
191
src/thirdparty/dirtysdk/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
cmake_minimum_required( VERSION 3.16 )
|
||||
add_module( "lib" "DirtySDK" "" ${FOLDER_CONTEXT} TRUE TRUE )
|
||||
|
||||
start_sources()
|
||||
|
||||
add_sources( SOURCE_GROUP "Platform"
|
||||
# Core source files
|
||||
"source/platform/plat-str.c"
|
||||
"source/platform/plat-time.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Comm"
|
||||
# Core source files
|
||||
"source/comm/commsrp.c"
|
||||
"source/comm/commudp.c"
|
||||
"source/comm/commudputil.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Crypto"
|
||||
# Core source files
|
||||
"source/crypt/cryptaes.c"
|
||||
"source/crypt/cryptarc4.c"
|
||||
"source/crypt/cryptchacha.c"
|
||||
"source/crypt/cryptcurve.c"
|
||||
"source/crypt/cryptgcm.c"
|
||||
"source/crypt/crypthash.c"
|
||||
"source/crypt/crypthmac.c"
|
||||
"source/crypt/cryptmd5.c"
|
||||
"source/crypt/cryptmont.c"
|
||||
"source/crypt/cryptnist.c"
|
||||
"source/crypt/cryptrandcommon.c"
|
||||
"source/crypt/cryptrsa.c"
|
||||
"source/crypt/cryptsha1.c"
|
||||
"source/crypt/cryptsha2.c"
|
||||
# Optional core source files
|
||||
"source/crypt/cryptbn.c"
|
||||
# PC plat source files
|
||||
"source/crypt/cryptrand.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Crypto/Include"
|
||||
# Core include files
|
||||
"source/crypt/cryptrandpriv.h"
|
||||
"source/crypt/cryptrandcommon.h"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Socket"
|
||||
# Core source files
|
||||
"source/dirtysock/dirtyaddr.c"
|
||||
"source/dirtysock/dirtycert.c"
|
||||
"source/dirtysock/dirtyerr.c"
|
||||
"source/dirtysock/dirtylib.c"
|
||||
"source/dirtysock/dirtylib.cpp"
|
||||
"source/dirtysock/dirtymem.c"
|
||||
"source/dirtysock/dirtynames.c"
|
||||
"source/dirtysock/dirtynet.c"
|
||||
"source/dirtysock/dirtythread.cpp"
|
||||
"source/dirtysock/dirtyuser.c"
|
||||
"source/dirtysock/netconn.c"
|
||||
"source/dirtysock/netconncommon.c"
|
||||
#"source/dirtysock/netconnlocaluser.cpp"
|
||||
# PC plat source files
|
||||
"source/dirtysock/dirtyaddr.c"
|
||||
"source/dirtysock/pc/dirtyerrpc.c"
|
||||
"source/dirtysock/pc/dirtylibwin.c"
|
||||
"source/dirtysock/pc/dirtynetwin.c"
|
||||
"source/dirtysock/pc/netconnwin.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Socket/Include"
|
||||
# Core include files
|
||||
"source/dirtysock/dirtynetpriv.h"
|
||||
"source/dirtysock/netconncommon.h"
|
||||
"source/dirtysock/netconnlocaluser.h"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Game"
|
||||
# Core source files
|
||||
"source/game/connapi.c"
|
||||
"source/game/netgamedist.c"
|
||||
"source/game/netgamedistserv.c"
|
||||
"source/game/netgamelink.c"
|
||||
"source/game/netgameutil.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Codec"
|
||||
# Core source files
|
||||
"source/graph/dirtygif.c"
|
||||
"source/graph/dirtygraph.c"
|
||||
"source/graph/dirtyjpg.c"
|
||||
"source/graph/dirtypng.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Misc"
|
||||
# Core source files
|
||||
"source/misc/qosclient.c"
|
||||
"source/misc/qoscommon.c"
|
||||
"source/misc/weblog.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Misc/Include"
|
||||
# Core include files
|
||||
"source/misc/userapipriv.h"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Protocol"
|
||||
# Core source files
|
||||
"source/proto/protoadvt.c"
|
||||
"source/proto/protohttpmanager.c"
|
||||
"source/proto/protohttpserv.c"
|
||||
"source/proto/protohttputil.c"
|
||||
"source/proto/protohttp2.c"
|
||||
"source/proto/protoname.c"
|
||||
"source/proto/protostream.c"
|
||||
"source/proto/prototunnel.c"
|
||||
"source/proto/protoupnp.c"
|
||||
# PC plat source files
|
||||
"source/proto/protohttp.c"
|
||||
"source/proto/protomangle.c"
|
||||
"source/proto/protossl.c"
|
||||
"source/proto/protowebsocket.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Utility"
|
||||
# Core source files
|
||||
"source/util/aws.c"
|
||||
"source/util/binary7.c"
|
||||
"source/util/base64.c"
|
||||
"source/util/hpack.c"
|
||||
"source/util/jsonformat.c"
|
||||
"source/util/jsonparse.c"
|
||||
"source/util/murmurhash3.c"
|
||||
"source/util/protobufcommon.c"
|
||||
"source/util/protobufread.c"
|
||||
"source/util/protobufwrite.c"
|
||||
"source/util/utf8.c"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Voip"
|
||||
# Core source files
|
||||
"source/voip/voiptunnel.c"
|
||||
"source/voip/voipgroup.c"
|
||||
# PC plat source files
|
||||
"source/voip/voip.c"
|
||||
"source/voip/voipblocklist.c"
|
||||
"source/voip/voipconduit.c"
|
||||
"source/voip/voipcodec.c"
|
||||
"source/voip/voipcommon.c"
|
||||
"source/voip/voipconnection.c"
|
||||
"source/voip/voipdvi.c"
|
||||
"source/voip/voipmixer.c"
|
||||
"source/voip/voippcm.c"
|
||||
"source/voip/pc/voipheadsetpc.c"
|
||||
"source/voip/pc/voippc.c"
|
||||
"source/voip/voiptranscribe.c"
|
||||
|
||||
"source/voip/pc/voipnarratepc.cpp"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Voip/Include"
|
||||
# Core include files
|
||||
"source/voip/voipcommon.h"
|
||||
"source/voip/voipconduit.h"
|
||||
"source/voip/voipconnection.h"
|
||||
"source/voip/voipdvi.h"
|
||||
"source/voip/voipmixer.h"
|
||||
"source/voip/voippacket.h"
|
||||
"source/voip/voippcm.h"
|
||||
"source/voip/voippriv.h"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "XML"
|
||||
# Core source files
|
||||
"source/xml/xmlformat.c"
|
||||
"source/xml/xmlparse.c"
|
||||
)
|
||||
|
||||
end_sources()
|
||||
thirdparty_suppress_warnings()
|
||||
|
||||
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/include/"
|
||||
"${THIRDPARTY_SOURCE_DIR}/ea/"
|
||||
"${THIRDPARTY_SOURCE_DIR}/ea/EAThread/include/"
|
||||
|
||||
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/source/crypt/"
|
||||
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/source/dirtysock/"
|
||||
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/source/voip/"
|
||||
)
|
||||
|
||||
target_compile_definitions( ${PROJECT_NAME} PRIVATE DIRTYCODE_LOGGING=0 )
|
6769
src/thirdparty/dirtysdk/changelog.txt
vendored
Normal file
6769
src/thirdparty/dirtysdk/changelog.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
143
src/thirdparty/dirtysdk/contrib/common/include/libsample/zfile.h
vendored
Normal file
143
src/thirdparty/dirtysdk/contrib/common/include/libsample/zfile.h
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File Zfile.h
|
||||
|
||||
\Description
|
||||
Host file operations.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 02/16/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _Zfile_h
|
||||
#define _Zfile_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#if (defined(DIRTYCODE_LINUX)) || (defined(DIRTYCODE_APPLEIOS))
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#if (defined(DIRTYCODE_LINUX)) || (defined(DIRTYCODE_APPLEIOS))
|
||||
#define ZFILE_INVALID (NULL)
|
||||
#else
|
||||
#define ZFILE_INVALID (-1) //!< an invalid ZfileT handle
|
||||
#endif
|
||||
|
||||
#define ZFILE_OPENFLAG_RDONLY (1)
|
||||
#define ZFILE_OPENFLAG_WRONLY (2)
|
||||
#define ZFILE_OPENFLAG_RDWR (ZFILE_OPENFLAG_RDONLY|ZFILE_OPENFLAG_WRONLY)
|
||||
#define ZFILE_OPENFLAG_CREATE (4)
|
||||
#define ZFILE_OPENFLAG_BINARY (8)
|
||||
#define ZFILE_OPENFLAG_APPEND (16)
|
||||
|
||||
#define ZFILE_SEEKFLAG_CUR (1)
|
||||
#define ZFILE_SEEKFLAG_END (2)
|
||||
#define ZFILE_SEEKFLAG_SET (3)
|
||||
|
||||
#define ZFILE_ERROR_NONE (0) //!< no error
|
||||
#define ZFILE_ERROR_FILEOPEN (-1) //!< generic error opening the file (reading or writing)
|
||||
#define ZFILE_ERROR_FILECLOSE (-2) //!< generic error closing the file
|
||||
#define ZFILE_ERROR_FILEWRITE (-3) //!< generic error occurred writing to the file
|
||||
#define ZFILE_ERROR_FILEDELETE (-4) //!< generic error deleting the file
|
||||
#define ZFILE_ERROR_FILESTAT (-5) //!< generic error trying to fstat a file
|
||||
#define ZFILE_ERROR_FILERENAME (-6) //!< generic error renaming a file
|
||||
#define ZFILE_ERROR_FILENAME (-7) //!< bad filename
|
||||
#define ZFILE_ERROR_NULLPOINTER (-8) //!< null pointer passed in where data was expected
|
||||
#define ZFILE_ERROR_NOSUCHFILE (-9) //!< file does not exist
|
||||
#define ZFILE_ERROR_PERMISSION (-10) //!< permission denied (on opening/writing)
|
||||
|
||||
#define ZFILE_PATHFILE_LENGTHMAX (512) //!< max length of a path/filename string
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
#define ZFILESTAT_MODE_READ (0x01) //!< file has read flag set
|
||||
#define ZFILESTAT_MODE_WRITE (0x02) //!< file has write flag set
|
||||
#define ZFILESTAT_MODE_EXECUTE (0x04) //!< file has execute flag set
|
||||
#define ZFILESTAT_MODE_PERMISSIONMASK (0x07) //!< mask for mode flags
|
||||
|
||||
#define ZFILESTAT_MODE_FILE (0x10) //!< item is a file
|
||||
#define ZFILESTAT_MODE_DIR (0x20) //!< item is a directory
|
||||
#define ZFILESTAT_MODE_FILETYPEMASK (0x30) //!< mask for file type flags
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct ZFileStatT
|
||||
{
|
||||
int64_t iSize; //!< file size in bytes
|
||||
uint32_t uTimeCreate; //!< file creation time, seconds since epoch
|
||||
uint32_t uTimeAccess; //!< last access time, seconds since epoch
|
||||
uint32_t uTimeModify; //!< last modification time, seconds since epoch
|
||||
uint16_t uMode; //!< file mode (file/dir and R/W/X)
|
||||
uint16_t uPad1; //!< pad out to even boundary
|
||||
} ZFileStatT;
|
||||
|
||||
#if !defined(DIRTYCODE_LINUX) && !defined(DIRTYCODE_APPLEIOS)
|
||||
typedef intptr_t ZFileT;
|
||||
#else
|
||||
typedef FILE * ZFileT;
|
||||
#endif
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Platform-specific implementations (Zfileplatform.c)
|
||||
*/
|
||||
|
||||
// open a file
|
||||
DIRTYCODE_API ZFileT ZFileOpen(const char *pFileName, uint32_t uFlags);
|
||||
|
||||
// close a file
|
||||
DIRTYCODE_API int32_t ZFileClose(ZFileT iFileId);
|
||||
|
||||
// read from a file
|
||||
DIRTYCODE_API int32_t ZFileRead(ZFileT iFileId, void *pData, int32_t iSize);
|
||||
|
||||
// write to a file
|
||||
DIRTYCODE_API int32_t ZFileWrite(ZFileT iFileId, void *pData, int32_t iSize);
|
||||
|
||||
// seek in a file
|
||||
DIRTYCODE_API int64_t ZFileSeek(ZFileT iFileId, int64_t iOffset, uint32_t uFlags);
|
||||
|
||||
// delete a file
|
||||
DIRTYCODE_API int32_t ZFileDelete(const char *pFileName);
|
||||
|
||||
// get file status information
|
||||
DIRTYCODE_API int32_t ZFileStat(const char *pFileName, ZFileStatT *pFileStat);
|
||||
|
||||
// rename a file
|
||||
DIRTYCODE_API int32_t ZFileRename(const char *pOldname, const char *pNewname);
|
||||
|
||||
// create a directory
|
||||
DIRTYCODE_API int32_t ZFileMkdir(const char *pPathName);
|
||||
|
||||
/*
|
||||
Platform-inspecific implementations (Zfile.c)
|
||||
*/
|
||||
|
||||
// get file size
|
||||
DIRTYCODE_API int64_t ZFileSize(ZFileT iFileId);
|
||||
|
||||
// open a file and load it into memory and null-terminate (in case it is a text file)
|
||||
DIRTYCODE_API char *ZFileLoad(const char *pFileName, int32_t *pFileSize, uint32_t bBinary);
|
||||
|
||||
// save (overwrite) null-terminated data to a file
|
||||
DIRTYCODE_API int32_t ZFileSave(const char *pFileName, const char *pData, int32_t iSize, uint32_t uFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _Zfile_h
|
||||
|
121
src/thirdparty/dirtysdk/contrib/common/include/libsample/zlib.h
vendored
Normal file
121
src/thirdparty/dirtysdk/contrib/common/include/libsample/zlib.h
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zlib.h
|
||||
|
||||
\Description
|
||||
A simple console style test library that provides a basic
|
||||
notion of processes, output routines and memory allocation.
|
||||
Used to implement simple test programs in a unix-style
|
||||
command-line environment.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 09/15/1999 (gschaefer) Initial Design
|
||||
\Version 11/08/1999 (gschaefer) Cleanup and revision
|
||||
\Version 03/17/2005 (jfrank) Cleanup and revision
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _zlib_h
|
||||
#define _zlib_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define ZLIB_STATUS_RUNNING ((signed)0x80000000)
|
||||
#define ZLIB_STATUS_UNKNOWN ((signed)0x80000001)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct ZEnviron ZEnviron;
|
||||
typedef struct ZContext ZContext;
|
||||
typedef struct ZConsole ZConsole;
|
||||
typedef int32_t (ZCommand)(ZContext *pArgz, int32_t iArgc, char **pArgv);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create a new process environment. Parses command line and gets process ready to run.
|
||||
DIRTYCODE_API ZEnviron *ZCreate(ZConsole *pConsole, const char *pCmdline);
|
||||
|
||||
// destroy process environment
|
||||
DIRTYCODE_API void ZDestroy(ZEnviron *pEnv);
|
||||
|
||||
// execute a process within an existing environment.
|
||||
DIRTYCODE_API void ZInvoke(ZEnviron *pEnv, ZCommand *pCmd);
|
||||
|
||||
// get process id of current process
|
||||
DIRTYCODE_API int32_t ZGetPid(void);
|
||||
|
||||
// set current environment from context
|
||||
DIRTYCODE_API void ZSet(ZContext *context);
|
||||
|
||||
// let process signal it wants a callback (has not completed).
|
||||
DIRTYCODE_API int32_t ZCallback(ZCommand *pCmd, int32_t iDelay);
|
||||
|
||||
// give time to any existing processes that need it.
|
||||
DIRTYCODE_API int32_t ZTask(void);
|
||||
|
||||
// remove any environments containing complete processes.
|
||||
DIRTYCODE_API void ZCleanup(void);
|
||||
|
||||
// kill all active processes in preparation for shutdown
|
||||
DIRTYCODE_API void ZShutdown(void);
|
||||
|
||||
// allow a process to allocate persistant private context.
|
||||
DIRTYCODE_API ZContext *ZContextCreate(int32_t iSize);
|
||||
|
||||
// return tick count in milliseconds.
|
||||
DIRTYCODE_API uint32_t ZTick(void);
|
||||
|
||||
// put process to sleep for some period of time
|
||||
DIRTYCODE_API void ZSleep(uint32_t uMSecs);
|
||||
|
||||
// display output using standard printf semantics.
|
||||
DIRTYCODE_API void ZPrintf(const char *pFmt, ...);
|
||||
|
||||
// display output using standard printf semantics (no hook)
|
||||
DIRTYCODE_API void ZPrintf2(const char *pFmt, ...);
|
||||
|
||||
#if DIRTYCODE_LOGGING
|
||||
#define ZPrintfDbg(_x) ZPrintf _x
|
||||
#else
|
||||
#define ZPrintfDbg(_x) { }
|
||||
#endif
|
||||
|
||||
// set zprint callback
|
||||
DIRTYCODE_API void ZPrintfHook(int32_t (*pPrintfHook)(void *pParm, const char *pText), void *pParm);
|
||||
|
||||
// show list of all process environments.
|
||||
DIRTYCODE_API int32_t ZCmdPS(ZContext *pArgz, int32_t iArgc, char **pArgv);
|
||||
|
||||
// kill an existing process.
|
||||
DIRTYCODE_API int32_t ZCmdKill(ZContext *pArgz, int32_t iArgc, char **pArgv);
|
||||
|
||||
// return status of current env, command.
|
||||
DIRTYCODE_API int32_t ZGetStatus(ZEnviron *pEnv);
|
||||
|
||||
// return status of process with specified pid
|
||||
DIRTYCODE_API int32_t ZGetStatusPid(int32_t iPid);
|
||||
|
||||
// get fourcc/integer from command-line argument
|
||||
DIRTYCODE_API int32_t ZGetIntArg(const char *pArg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _zlib_h
|
||||
|
||||
|
63
src/thirdparty/dirtysdk/contrib/common/include/libsample/zlist.h
vendored
Normal file
63
src/thirdparty/dirtysdk/contrib/common/include/libsample/zlist.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zlist.h
|
||||
|
||||
\Description
|
||||
Generic list module for samples to use.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 04/26/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _zlist_h
|
||||
#define _zlist_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define ZLIST_ERROR_NONE (0) //!< no error (success)
|
||||
#define ZLIST_ERROR_NULLPOINTER (-1) //!< a null pointer ref was used
|
||||
#define ZLIST_ERROR_FULL (-2) //!< sending/receiving list is full (msg dropped)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct ZListT ZListT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create a list object
|
||||
DIRTYCODE_API ZListT *ZListCreate(int32_t iNumEntries, int32_t iEntrySize);
|
||||
|
||||
// add an entry to the back of a data list
|
||||
DIRTYCODE_API int32_t ZListPushBack(ZListT *pList, void *pEntry);
|
||||
|
||||
// get an entry off the front of a data list
|
||||
DIRTYCODE_API int32_t ZListPopFront(ZListT *pList, void *pEntry);
|
||||
|
||||
// examine the front entry of a data list
|
||||
DIRTYCODE_API void *ZListPeekFront(ZListT *pList);
|
||||
|
||||
// erase and entire list
|
||||
DIRTYCODE_API void ZListClear(ZListT *pList);
|
||||
|
||||
// destroy a list object
|
||||
DIRTYCODE_API void ZListDestroy(ZListT *pList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _zlist_h
|
||||
|
48
src/thirdparty/dirtysdk/contrib/common/include/libsample/zmem.h
vendored
Normal file
48
src/thirdparty/dirtysdk/contrib/common/include/libsample/zmem.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zmem.h
|
||||
|
||||
\Description
|
||||
ZAlloc (malloc) and ZFree (free) implementations for use on all platforms.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _zmem_h
|
||||
#define _zmem_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
// include this so we can use zmemtrack alongside the zmem libraries
|
||||
#include "zmemtrack.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate some memory, uSize bytes in length
|
||||
DIRTYCODE_API void *ZMemAlloc(uint32_t uSize);
|
||||
|
||||
// free a previously allocated memory chunk
|
||||
DIRTYCODE_API uint32_t ZMemFree(void *pMem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _zmem_h
|
||||
|
62
src/thirdparty/dirtysdk/contrib/common/include/libsample/zmemtrack.h
vendored
Normal file
62
src/thirdparty/dirtysdk/contrib/common/include/libsample/zmemtrack.h
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zmemtrack.h
|
||||
|
||||
\Description
|
||||
Routines for tracking memory allocations.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 02/15/2005 (jbrookes) First Version, based on jfrank's implementation.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _zmemtrack_h
|
||||
#define _zmemtrack_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define ZMEMTRACK_PRINTFLAG_TRACKING (1) //!< print more verbose output
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! logging function
|
||||
typedef void (ZMemtrackLogCbT)(const char *pText, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init Zmemtrack module
|
||||
DIRTYCODE_API void ZMemtrackStartup(void);
|
||||
|
||||
// shut down Zmemtrack module
|
||||
DIRTYCODE_API void ZMemtrackShutdown(void);
|
||||
|
||||
// set the logging callback
|
||||
DIRTYCODE_API void ZMemtrackCallback(ZMemtrackLogCbT *pLoggingCb, void *pUserData);
|
||||
|
||||
// track an allocation
|
||||
DIRTYCODE_API void ZMemtrackAlloc(void *pMem, uint32_t uSize, uint32_t uTag);
|
||||
|
||||
// track a free operation
|
||||
DIRTYCODE_API void ZMemtrackFree(void *pMem, uint32_t *pSize);
|
||||
|
||||
// print current tracking info
|
||||
DIRTYCODE_API void ZMemtrackPrint(uint32_t uFlags, uint32_t uTag, const char *pModuleName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _zmemtrack_h
|
||||
|
404
src/thirdparty/dirtysdk/contrib/common/source/pc/zfilepc.c
vendored
Normal file
404
src/thirdparty/dirtysdk/contrib/common/source/pc/zfilepc.c
vendored
Normal file
@ -0,0 +1,404 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zfilepc.c
|
||||
|
||||
\Description
|
||||
Basic file operations (open, read, write, close, size).
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2004. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 11/18/1004 (jbrookes) First Version
|
||||
\Version 1.1 03/16/2005 (jfrank) Updates for common sample libraries
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <direct.h> // _mkdir
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
|
||||
#include "zfile.h"
|
||||
#include "zlib.h"
|
||||
#include "zmem.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileOpen
|
||||
|
||||
\Description
|
||||
Open a file.
|
||||
|
||||
\Input *pFileName - file name to open
|
||||
\Input uFlags - flags dictating how to open the file
|
||||
|
||||
\Output
|
||||
int32_t - file descriptor, or -1 if there was an error
|
||||
|
||||
\Version 1.0 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
ZFileT ZFileOpen(const char *pFileName, uint32_t uFlags)
|
||||
{
|
||||
char strMode[16] = "";
|
||||
FILE *pFile;
|
||||
|
||||
if(pFileName == NULL)
|
||||
return(ZFILE_INVALID);
|
||||
if(strlen(pFileName) == 0)
|
||||
return(ZFILE_INVALID);
|
||||
|
||||
ds_memclr(strMode, sizeof(strMode));
|
||||
|
||||
// map zfile flags to Win32 Mode flags
|
||||
if (uFlags & ZFILE_OPENFLAG_APPEND)
|
||||
{
|
||||
strcat(strMode, "a");
|
||||
if (uFlags & ZFILE_OPENFLAG_RDONLY)
|
||||
strcat(strMode, "+");
|
||||
}
|
||||
else if (uFlags & ZFILE_OPENFLAG_RDONLY)
|
||||
{
|
||||
strcat(strMode, "r");
|
||||
if (uFlags & ZFILE_OPENFLAG_WRONLY)
|
||||
strcat(strMode, "+");
|
||||
}
|
||||
else if (uFlags & ZFILE_OPENFLAG_WRONLY)
|
||||
strcat(strMode, "w");
|
||||
if (uFlags & ZFILE_OPENFLAG_BINARY)
|
||||
strcat(strMode, "b");
|
||||
|
||||
if ((pFile = fopen(pFileName, strMode)) != NULL)
|
||||
{
|
||||
return((ZFileT)pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZPrintfDbg(("zfilepc: error %d opening file '%s'\n", errno, pFileName));
|
||||
return(ZFILE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileClose
|
||||
|
||||
\Description
|
||||
Close a file
|
||||
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output int32_t - return value from fclose()
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileClose(ZFileT iFileId)
|
||||
{
|
||||
if (iFileId != ZFILE_INVALID)
|
||||
{
|
||||
return(fclose((FILE *)iFileId));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(ZFILE_ERROR_FILECLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileRead
|
||||
|
||||
\Description
|
||||
Read from a file.
|
||||
|
||||
\Input *pData - pointer to buffer to read to
|
||||
\Input iSize - amount of data to read
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output
|
||||
Number of bytes read
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileRead(ZFileT iFileId, void *pData, int32_t iSize)
|
||||
{
|
||||
int32_t iResult;
|
||||
|
||||
iResult = (int32_t)fread(pData, 1, iSize, (FILE *)iFileId);
|
||||
|
||||
return(ferror((FILE *)iFileId) ? 0 : iResult);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileWrite
|
||||
|
||||
\Description
|
||||
Write to a file.
|
||||
|
||||
\Input *pData - pointer to buffer to write from
|
||||
\Input iSize - amount of data to write
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output
|
||||
Number of bytes written
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileWrite(ZFileT iFileId, void *pData, int32_t iSize)
|
||||
{
|
||||
if ((iFileId == ZFILE_INVALID) || (pData == NULL) || (iSize == 0))
|
||||
{
|
||||
return(ZFILE_ERROR_FILEWRITE);
|
||||
}
|
||||
return((int32_t)fwrite(pData, 1, iSize, (FILE *)iFileId));
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileSeek
|
||||
|
||||
\Description
|
||||
Seek to location in file.
|
||||
|
||||
\Input iFileId - file id to seek
|
||||
\Input iOffset - offset to seek to
|
||||
\Input uFlags - seek mode (ZFILE_SEEKFLAG_*)
|
||||
|
||||
\Output
|
||||
int64_t - resultant seek location, or -1 on error
|
||||
|
||||
\Version 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int64_t ZFileSeek(ZFileT iFileId, int64_t iOffset, uint32_t uFlags)
|
||||
{
|
||||
int64_t iResult;
|
||||
int32_t iFlags=0;
|
||||
|
||||
if (uFlags == ZFILE_SEEKFLAG_CUR)
|
||||
iFlags = SEEK_CUR;
|
||||
else if (uFlags == ZFILE_SEEKFLAG_END)
|
||||
iFlags = SEEK_END;
|
||||
else if (uFlags == ZFILE_SEEKFLAG_SET)
|
||||
iFlags = SEEK_SET;
|
||||
|
||||
iResult = _fseeki64((FILE *)iFileId, iOffset, iFlags);
|
||||
iResult = _ftelli64((FILE *)iFileId);
|
||||
return((iResult >= 0) ? iResult : -1);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileDelete
|
||||
|
||||
\Description
|
||||
Delete a file.
|
||||
|
||||
\Input *pFileName - filename of file to delete
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/23/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileDelete(const char *pFileName)
|
||||
{
|
||||
int32_t iResult;
|
||||
|
||||
if(pFileName == NULL)
|
||||
return(ZFILE_ERROR_FILENAME);
|
||||
|
||||
iResult = remove(pFileName);
|
||||
if(iResult == 0)
|
||||
return(ZFILE_ERROR_NONE);
|
||||
else
|
||||
return(ZFILE_ERROR_FILEDELETE);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileStat
|
||||
|
||||
\Description
|
||||
Get File Stat information on a file/dir.
|
||||
|
||||
\Input *pFileName - filename/dir to stat
|
||||
\Input *pStat
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/25/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileStat(const char *pFileName, ZFileStatT *pFileStat)
|
||||
{
|
||||
struct _stat FileStat;
|
||||
int32_t iResult;
|
||||
|
||||
// check for error conditions
|
||||
if(pFileName == NULL)
|
||||
return(ZFILE_ERROR_FILENAME);
|
||||
if(pFileStat == NULL)
|
||||
return(ZFILE_ERROR_NULLPOINTER);
|
||||
|
||||
// get file status
|
||||
iResult = _stat(pFileName, &FileStat);
|
||||
|
||||
// check for some specific errors
|
||||
if((iResult == -1) && (errno == ENOENT))
|
||||
return(ZFILE_ERROR_NOSUCHFILE);
|
||||
else if(errno == EACCES)
|
||||
return(ZFILE_ERROR_PERMISSION);
|
||||
else if(iResult != 0)
|
||||
return(ZFILE_ERROR_FILESTAT);
|
||||
|
||||
// clear the incoming buffer
|
||||
ds_memclr(pFileStat, sizeof(ZFileStatT));
|
||||
// copy from the PC-specific structures
|
||||
pFileStat->iSize = FileStat.st_size;
|
||||
pFileStat->uTimeAccess = FileStat.st_atime;
|
||||
pFileStat->uTimeCreate = FileStat.st_ctime;
|
||||
pFileStat->uTimeModify = FileStat.st_mtime;
|
||||
// get the file modes
|
||||
if(FileStat.st_mode & _S_IFDIR)
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_DIR;
|
||||
if(FileStat.st_mode & _S_IFREG)
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_FILE;
|
||||
if(FileStat.st_mode & _S_IREAD)
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_READ;
|
||||
if(FileStat.st_mode & _S_IWRITE)
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_WRITE;
|
||||
if(FileStat.st_mode & _S_IEXEC)
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_EXECUTE;
|
||||
|
||||
// done - return no error
|
||||
return(ZFILE_ERROR_NONE);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileRename
|
||||
|
||||
\Description
|
||||
Rename a file.
|
||||
|
||||
\Input *pOldname - old name
|
||||
\Input *pNewname - new name
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/30/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileRename(const char *pOldname, const char *pNewname)
|
||||
{
|
||||
int32_t iResult;
|
||||
|
||||
// check for error conditions
|
||||
if((pOldname == NULL) || (pNewname == NULL))
|
||||
return(ZFILE_ERROR_NULLPOINTER);
|
||||
|
||||
// rename the file
|
||||
iResult = rename(pOldname, pNewname);
|
||||
|
||||
if(iResult == 0)
|
||||
return(ZFILE_ERROR_NONE);
|
||||
else
|
||||
return(ZFILE_ERROR_FILERENAME);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileMkdir
|
||||
|
||||
\Description
|
||||
Make a directory, recursively
|
||||
|
||||
\Input *pPathName - directory path to create
|
||||
|
||||
\Output
|
||||
int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 01/25/2012 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileMkdir(const char *pPathName)
|
||||
{
|
||||
char strPath[1024], *pPath, cTerm = '\0';
|
||||
|
||||
// copy pathname
|
||||
ds_strnzcpy(strPath, pPathName, sizeof(strPath));
|
||||
|
||||
// translate forward slashes to backward slashes
|
||||
for (pPath = strPath; *pPath != '\0'; pPath += 1)
|
||||
{
|
||||
if (*pPath == '/')
|
||||
{
|
||||
*pPath = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
// traverse pathname, making each directory component as we go
|
||||
for (pPath = strPath; ; pPath += 1)
|
||||
{
|
||||
if (*pPath == '\\')
|
||||
{
|
||||
cTerm = *pPath;
|
||||
*pPath = '\0';
|
||||
}
|
||||
if (*pPath == '\0')
|
||||
{
|
||||
int32_t iResult;
|
||||
if ((iResult = _mkdir(strPath)) != 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
ZPrintfDbg(("zfilepc: could not create directory '%s'\n", strPath));
|
||||
return(-1);
|
||||
}
|
||||
if (errno == EEXIST)
|
||||
{
|
||||
ZPrintfDbg(("zfilepc: directory %s already exists\n", strPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cTerm != '\0')
|
||||
{
|
||||
*pPath = cTerm;
|
||||
cTerm = '\0';
|
||||
}
|
||||
if (*pPath == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
472
src/thirdparty/dirtysdk/contrib/common/source/unix/zfileunix.c
vendored
Normal file
472
src/thirdparty/dirtysdk/contrib/common/source/unix/zfileunix.c
vendored
Normal file
@ -0,0 +1,472 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zfilepc.c
|
||||
|
||||
\Description
|
||||
Basic file operations (open, read, write, close, size).
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2004. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 11/18/1004 (jbrookes) First Version
|
||||
\Version 1.1 03/16/2005 (jfrank) Updates for common sample libraries
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyerr.h"
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
|
||||
#include "zfile.h"
|
||||
#include "zlib.h"
|
||||
#include "zmem.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function _ZFilePathTranslate
|
||||
|
||||
\Description
|
||||
Translate a path from dos-style to unix-style
|
||||
|
||||
\Input *pPathName - path name to translate
|
||||
\Input *pStrBuf - [out] output for translated path
|
||||
\Input iBufLen - size of output buffer
|
||||
|
||||
\Output
|
||||
char * - pointer to translated path
|
||||
|
||||
\Version 10/10/2013 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
static char *_ZFilePathTranslate(const char *pPathName, char *pStrBuf, int32_t iBufLen)
|
||||
{
|
||||
char *pPath;
|
||||
|
||||
// copy pathname
|
||||
ds_strnzcpy(pStrBuf, pPathName, iBufLen);
|
||||
|
||||
// translate any backward slashes to forward slashes
|
||||
for (pPath = pStrBuf; *pPath != '\0'; pPath += 1)
|
||||
{
|
||||
if (*pPath == '\\')
|
||||
{
|
||||
*pPath = '/';
|
||||
}
|
||||
}
|
||||
return(pStrBuf);
|
||||
}
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileOpen
|
||||
|
||||
\Description
|
||||
Open a file.
|
||||
|
||||
\Input *pFileName - file name to open
|
||||
\Input uFlags - flags dictating how to open the file
|
||||
|
||||
\Output
|
||||
int32_t - file descriptor, or -1 if there was an error
|
||||
|
||||
\Version 1.0 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
ZFileT ZFileOpen(const char *pFileName, uint32_t uFlags)
|
||||
{
|
||||
char strFileName[4096];
|
||||
char strMode[16] = "";
|
||||
FILE *pFile;
|
||||
|
||||
if ((pFileName == NULL) || (pFileName[0] == '\0'))
|
||||
{
|
||||
return(ZFILE_INVALID);
|
||||
}
|
||||
|
||||
pFileName = _ZFilePathTranslate(pFileName, strFileName, sizeof(strFileName));
|
||||
|
||||
ds_memclr(strMode, sizeof(strMode));
|
||||
|
||||
// map zfile flags to Win32 Mode flags
|
||||
if (uFlags & ZFILE_OPENFLAG_APPEND)
|
||||
{
|
||||
strcat(strMode, "a");
|
||||
if (uFlags & ZFILE_OPENFLAG_RDONLY)
|
||||
strcat(strMode, "+");
|
||||
}
|
||||
else if (uFlags & ZFILE_OPENFLAG_RDONLY)
|
||||
{
|
||||
strcat(strMode, "r");
|
||||
if (uFlags & ZFILE_OPENFLAG_WRONLY)
|
||||
strcat(strMode, "+");
|
||||
}
|
||||
else if (uFlags & ZFILE_OPENFLAG_WRONLY)
|
||||
{
|
||||
strcat(strMode, "w");
|
||||
}
|
||||
if (uFlags & ZFILE_OPENFLAG_BINARY)
|
||||
{
|
||||
strcat(strMode, "b");
|
||||
}
|
||||
|
||||
if ((pFile = fopen(pFileName, strMode)) != NULL)
|
||||
{
|
||||
return((ZFileT)pFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(ZFILE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileClose
|
||||
|
||||
\Description
|
||||
Close a file
|
||||
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output int32_t - return value from fclose()
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileClose(ZFileT iFileId)
|
||||
{
|
||||
return(fclose((FILE *)iFileId));
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileRead
|
||||
|
||||
\Description
|
||||
Read from a file.
|
||||
|
||||
\Input *pData - pointer to buffer to read to
|
||||
\Input iSize - amount of data to read
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output
|
||||
Number of bytes read
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileRead(ZFileT iFileId, void *pData, int32_t iSize)
|
||||
{
|
||||
int32_t iResult = (int32_t)fread(pData, 1, iSize, (FILE *)iFileId);
|
||||
return(ferror((FILE *)iFileId) ? -1 : iResult);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileWrite
|
||||
|
||||
\Description
|
||||
Write to a file.
|
||||
|
||||
\Input *pData - pointer to buffer to write from
|
||||
\Input iSize - amount of data to write
|
||||
\Input iFileId - file descriptor
|
||||
|
||||
\Output
|
||||
Number of bytes written
|
||||
|
||||
\Version 1.0 11/18/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileWrite(ZFileT iFileId, void *pData, int32_t iSize)
|
||||
{
|
||||
int32_t iResult;
|
||||
|
||||
if (iFileId == ZFILE_INVALID)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
if ((pData == NULL) || (iSize == 0))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
iResult = (int32_t)fwrite(pData, 1, iSize, (FILE *)iFileId);
|
||||
return(iResult);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileSeek
|
||||
|
||||
\Description
|
||||
Seek to location in file.
|
||||
|
||||
\Input iFileId - file id to seek
|
||||
\Input iOffset - offset to seek to
|
||||
\Input uFlags - seek mode (ZFILE_SEEKFLAG_*)
|
||||
|
||||
\Output
|
||||
int64_t - resultant seek location, or -1 on error
|
||||
|
||||
\Version 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int64_t ZFileSeek(ZFileT iFileId, int64_t iOffset, uint32_t uFlags)
|
||||
{
|
||||
int64_t iResult;
|
||||
int32_t iFlags=0;
|
||||
|
||||
if (uFlags == ZFILE_SEEKFLAG_CUR)
|
||||
{
|
||||
iFlags = SEEK_CUR;
|
||||
}
|
||||
else if (uFlags == ZFILE_SEEKFLAG_END)
|
||||
{
|
||||
iFlags = SEEK_END;
|
||||
}
|
||||
else if (uFlags == ZFILE_SEEKFLAG_SET)
|
||||
{
|
||||
iFlags = SEEK_SET;
|
||||
}
|
||||
|
||||
fseek((FILE *)iFileId, iOffset, iFlags);
|
||||
iResult = ftell((FILE *)iFileId);
|
||||
return((iResult >= 0) ? iResult : -1);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileDelete
|
||||
|
||||
\Description
|
||||
Delete a file.
|
||||
|
||||
\Input *pFileName - filename of file to delete
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/23/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileDelete(const char *pFileName)
|
||||
{
|
||||
char strFileName[4096];
|
||||
int32_t iResult;
|
||||
|
||||
if ((pFileName == NULL) || (pFileName[0] == '\0'))
|
||||
{
|
||||
return(ZFILE_ERROR_FILENAME);
|
||||
}
|
||||
|
||||
pFileName = _ZFilePathTranslate(pFileName, strFileName, sizeof(strFileName));
|
||||
|
||||
iResult = remove(pFileName);
|
||||
if (iResult == 0)
|
||||
{
|
||||
return(ZFILE_ERROR_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(ZFILE_ERROR_FILEDELETE);
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileStat
|
||||
|
||||
\Description
|
||||
Get File Stat information on a file/dir.
|
||||
|
||||
\Input *pFileName - filename/dir to stat
|
||||
\Input *pStat
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/25/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileStat(const char *pFileName, ZFileStatT *pFileStat)
|
||||
{
|
||||
#if !defined(DIRTYCODE_NX)
|
||||
char strFileName[4096];
|
||||
struct stat FileStat;
|
||||
int32_t iResult;
|
||||
|
||||
// check for error conditions
|
||||
if (pFileName == NULL)
|
||||
{
|
||||
return(ZFILE_ERROR_FILENAME);
|
||||
}
|
||||
if (pFileStat == NULL)
|
||||
{
|
||||
return(ZFILE_ERROR_NULLPOINTER);
|
||||
}
|
||||
|
||||
pFileName = _ZFilePathTranslate(pFileName, strFileName, sizeof(strFileName));
|
||||
|
||||
// get file status
|
||||
iResult = stat(pFileName, &FileStat);
|
||||
|
||||
// check for some specific errors
|
||||
if ((iResult == -1) && (errno == ENOENT))
|
||||
{
|
||||
return(ZFILE_ERROR_NOSUCHFILE);
|
||||
}
|
||||
else if (errno == EACCES)
|
||||
{
|
||||
return(ZFILE_ERROR_PERMISSION);
|
||||
}
|
||||
else if (iResult != 0)
|
||||
{
|
||||
return(ZFILE_ERROR_FILESTAT);
|
||||
}
|
||||
|
||||
// clear the incoming buffer
|
||||
ds_memclr(pFileStat, sizeof(ZFileStatT));
|
||||
// copy from the PC-specific structures
|
||||
pFileStat->iSize = FileStat.st_size;
|
||||
pFileStat->uTimeAccess = (uint32_t)FileStat.st_atime;
|
||||
pFileStat->uTimeCreate = (uint32_t)FileStat.st_ctime;
|
||||
pFileStat->uTimeModify = (uint32_t)FileStat.st_mtime;
|
||||
// get the file modes
|
||||
if (S_ISDIR(FileStat.st_mode))
|
||||
{
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_DIR;
|
||||
}
|
||||
if (S_ISREG(FileStat.st_mode))
|
||||
{
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_FILE;
|
||||
}
|
||||
if (FileStat.st_mode & S_IRUSR)
|
||||
{
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_READ;
|
||||
}
|
||||
if (FileStat.st_mode & S_IWUSR)
|
||||
{
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_WRITE;
|
||||
}
|
||||
if (FileStat.st_mode & S_IXUSR)
|
||||
{
|
||||
pFileStat->uMode |= ZFILESTAT_MODE_EXECUTE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// done - return no error
|
||||
return(ZFILE_ERROR_NONE);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileRename
|
||||
|
||||
\Description
|
||||
Rename a file.
|
||||
|
||||
\Input *pOldname - old name
|
||||
\Input *pNewname - new name
|
||||
|
||||
\Output int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 03/30/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileRename(const char *pOldname, const char *pNewname)
|
||||
{
|
||||
int32_t iResult;
|
||||
|
||||
// check for error conditions
|
||||
if ((pOldname == NULL) || (pNewname == NULL))
|
||||
{
|
||||
return(ZFILE_ERROR_NULLPOINTER);
|
||||
}
|
||||
|
||||
// rename the file
|
||||
iResult = rename(pOldname, pNewname);
|
||||
|
||||
return((iResult == 0) ? ZFILE_ERROR_NONE : ZFILE_ERROR_FILERENAME);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileMkdir
|
||||
|
||||
\Description
|
||||
Make a directory, recursively
|
||||
|
||||
\Input *pPathName - directory path to create
|
||||
|
||||
\Output
|
||||
int32_t - 0=success, error code otherwise
|
||||
|
||||
\Version 01/25/2012 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileMkdir(const char *pPathName)
|
||||
{
|
||||
char strPathName[4096], *pPath, cTerm = '\0';
|
||||
|
||||
pPath = _ZFilePathTranslate(pPathName, strPathName, sizeof(strPathName));
|
||||
|
||||
// traverse pathname, making each directory component as we go
|
||||
for ( ; ; pPath += 1)
|
||||
{
|
||||
if (*pPath == '/')
|
||||
{
|
||||
cTerm = *pPath;
|
||||
*pPath = '\0';
|
||||
}
|
||||
if (*pPath == '\0')
|
||||
{
|
||||
int32_t iResult;
|
||||
if ((iResult = mkdir(strPathName, S_IRWXU)) != 0)
|
||||
{
|
||||
if (errno == EEXIST)
|
||||
{
|
||||
ZPrintfDbg(("zfilepc: directory %s already exists\n", strPathName));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZPrintfDbg(("zfileunix: could not create directory '%s' err=%s\n", strPathName, DirtyErrGetName(errno)));
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cTerm != '\0')
|
||||
{
|
||||
*pPath = cTerm;
|
||||
cTerm = '\0';
|
||||
}
|
||||
if (*pPath == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
199
src/thirdparty/dirtysdk/contrib/common/source/zfile.c
vendored
Normal file
199
src/thirdparty/dirtysdk/contrib/common/source/zfile.c
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zfile.c
|
||||
|
||||
\Description
|
||||
Platform-inspecific host file operations.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 02/16/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "zmem.h"
|
||||
#include "zlib.h"
|
||||
#include "zfile.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileSize
|
||||
|
||||
\Description
|
||||
Get file size.
|
||||
|
||||
\Input iFileId - file id to get size of
|
||||
|
||||
\Output
|
||||
int32_t - file size, or -1 on error
|
||||
|
||||
\Version 02/16/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int64_t ZFileSize(ZFileT iFileId)
|
||||
{
|
||||
int64_t iEnd = ZFileSeek(iFileId, 0, ZFILE_SEEKFLAG_END);
|
||||
ZFileSeek(iFileId, 0, ZFILE_SEEKFLAG_SET);
|
||||
return(iEnd);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileLoad
|
||||
|
||||
\Description
|
||||
Open a file and read it into memory.
|
||||
|
||||
\Input *pFilename - pointer to name of file to read
|
||||
\Input *pFileSize - [out] storage for file size
|
||||
\Input uOpenFlags - open flags, or zero for default (READONLY)
|
||||
|
||||
\Output
|
||||
char * - pointer to file data, or NULL
|
||||
|
||||
\Version 02/16/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
char *ZFileLoad(const char *pFileName, int32_t *pFileSize, uint32_t uOpenFlags)
|
||||
{
|
||||
int64_t iFileSize64;
|
||||
int32_t iFileSize, iResult;
|
||||
char *pFileMem;
|
||||
ZFileT iFileId;
|
||||
|
||||
// determine open flags
|
||||
if (uOpenFlags == 0)
|
||||
{
|
||||
uOpenFlags = ZFILE_OPENFLAG_RDONLY;
|
||||
}
|
||||
|
||||
// open the file
|
||||
iFileId = ZFileOpen(pFileName, uOpenFlags);
|
||||
if (iFileId == ZFILE_INVALID)
|
||||
{
|
||||
printf("zfile: unable to open file '%s'\n", pFileName);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// get the file size
|
||||
iFileSize64 = ZFileSize(iFileId);
|
||||
if (iFileSize64 < 0)
|
||||
{
|
||||
printf("zfile: unable to get size of file '%s'\n", pFileName);
|
||||
return(NULL);
|
||||
}
|
||||
iFileSize = (int32_t)iFileSize64; // this function does not support files >2GB
|
||||
|
||||
// allocate and clear memory for the file
|
||||
pFileMem = (char *) ZMemAlloc(iFileSize+1);
|
||||
if (pFileMem == NULL)
|
||||
{
|
||||
printf("zfile: unable to allocate %d bytes to load file '%s'\n", iFileSize+1, pFileName);
|
||||
return(NULL);
|
||||
}
|
||||
ds_memclr(pFileMem, iFileSize+1);
|
||||
|
||||
// read file into memory
|
||||
iResult = ZFileRead(iFileId, pFileMem, iFileSize);
|
||||
if (iResult <= 0)
|
||||
{
|
||||
printf("zfile: unable to read file '%s'\n", pFileName);
|
||||
return(NULL);
|
||||
}
|
||||
/* null-terminate; we do this in addition to the memset up above because
|
||||
under windows the size of a text file on disk may be larger than the
|
||||
file in memory */
|
||||
pFileMem[iResult] = '\0';
|
||||
|
||||
// if size parameter is not null, set it
|
||||
if (pFileSize != NULL)
|
||||
{
|
||||
*pFileSize = iResult;
|
||||
}
|
||||
|
||||
// close the file
|
||||
iResult = ZFileClose(iFileId);
|
||||
if (iResult < 0)
|
||||
{
|
||||
printf("zfile: error closing file '%s'\n", pFileName);
|
||||
}
|
||||
|
||||
// return pointer to memory
|
||||
return(pFileMem);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZFileSave
|
||||
|
||||
\Description
|
||||
Save data to a file. (OVERWRITE and CREATE by default)
|
||||
|
||||
\Input *pFilename - pointer to name of file to read
|
||||
\Input *pData - pointer to data to save to a file
|
||||
\Input iSize - amount of data to save to the file
|
||||
\Input uOpenFlags - open flags, or zero for default (WRONLY|CREATE)
|
||||
|
||||
\Output
|
||||
int32_t - 0 if success, error code otherwise
|
||||
|
||||
\Version 03/18/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZFileSave(const char *pFileName, const char *pData, int32_t iSize, uint32_t uOpenFlags)
|
||||
{
|
||||
int32_t iResult;
|
||||
ZFileT iFileId;
|
||||
|
||||
// determine what flags to use
|
||||
if (uOpenFlags == 0)
|
||||
{
|
||||
uOpenFlags = ZFILE_OPENFLAG_WRONLY | ZFILE_OPENFLAG_CREATE;
|
||||
}
|
||||
|
||||
// open the file
|
||||
iFileId = ZFileOpen(pFileName, uOpenFlags);
|
||||
if (iFileId == ZFILE_INVALID)
|
||||
{
|
||||
ZPrintf("zfile: unable to open file '%s' with flags 0x%X\n", pFileName, uOpenFlags);
|
||||
return(ZFILE_ERROR_FILEOPEN);
|
||||
}
|
||||
|
||||
// now write the data
|
||||
iResult = ZFileWrite(iFileId, (char *)pData, iSize);
|
||||
if(iResult != iSize)
|
||||
{
|
||||
ZPrintf("zfile: write error - size to write [%d] size written [%d]\n", iSize, iResult);
|
||||
return(ZFILE_ERROR_FILEWRITE);
|
||||
}
|
||||
|
||||
// and close the file
|
||||
iResult = ZFileClose(iFileId);
|
||||
if(iResult != 0)
|
||||
{
|
||||
ZPrintf("zfile: close error [%d=0x%X]\n", iResult, iResult);
|
||||
return(ZFILE_ERROR_FILECLOSE);
|
||||
}
|
||||
|
||||
// else successful save occurred
|
||||
return(ZFILE_ERROR_NONE);
|
||||
}
|
||||
|
805
src/thirdparty/dirtysdk/contrib/common/source/zlib.c
vendored
Normal file
805
src/thirdparty/dirtysdk/contrib/common/source/zlib.c
vendored
Normal file
@ -0,0 +1,805 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zlib.c
|
||||
|
||||
\Description
|
||||
A simple console style test library that provides a basic
|
||||
notion of processes, output routines and memory allocation.
|
||||
Used to implement simple test programs in a unix-style
|
||||
command-line environment.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 09/15/1999 (gschaefer) Initial Design
|
||||
\Version 11/08/1999 (gschaefer) Cleanup and revision
|
||||
\Version 03/17/2005 (jfrank) Cleanup and revision
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#pragma warning(push,0)
|
||||
#include <windows.h>
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
#include "DirtySDK/dirtydefs.h"
|
||||
#include "DirtySDK/dirtysock.h"
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
#include "DirtySDK/dirtysock/netconn.h"
|
||||
#include "zlib.h"
|
||||
#include "zmem.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#if !defined(_WIN32) || defined(DIRTYCODE_XBOXONE) || defined(DIRTYCODE_GDK)
|
||||
#define wsprintf sprintf
|
||||
#endif
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
struct ZEnviron
|
||||
{
|
||||
ZEnviron *pNext; //!< list of active process contexts
|
||||
ZContext *pContext; //!< process private context
|
||||
ZConsole *pConsole; //!< console output pointer
|
||||
ZCommand *pCommand; //!< pointer to process code
|
||||
|
||||
uint32_t uRuntime; //!< number of ms process has run
|
||||
uint32_t uRuncount; //!< number of time slices
|
||||
|
||||
int32_t iPID; //!< process identifier
|
||||
int32_t iStatus; //!< exit status
|
||||
uint32_t uSchedule; //!< next scheduled tick to run at
|
||||
|
||||
int32_t iArgc; //!< arg count for program
|
||||
char *pArgv[200]; //!< pointer to entry parms
|
||||
char strArgb[16*1024]; //!< buffer to hold entry parms
|
||||
};
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
static ZEnviron *_pEnvCurr = NULL; //!< current process
|
||||
static ZEnviron *_pEnvList = NULL; //!< list of processes
|
||||
|
||||
static void *_Zlib_pPrintfParm = NULL;
|
||||
static int32_t (*_Zlib_pPrintfHook)(void *pParm, const char *pText) = NULL;
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCreate
|
||||
|
||||
\Description
|
||||
Create a new process environment. Parses command line
|
||||
and gets process ready to run.
|
||||
|
||||
\Input console - default output console for process
|
||||
\Input cmdline - the entry command line params
|
||||
|
||||
\Output ZEnviron - new process environment
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
ZEnviron *ZCreate(ZConsole *console, const char *cmdline)
|
||||
{
|
||||
char term;
|
||||
char *s;
|
||||
ZEnviron *env;
|
||||
static uint32_t pid = 1;
|
||||
|
||||
// get new environment
|
||||
env = (ZEnviron *)ZMemAlloc(sizeof(*env));
|
||||
ds_memclr(env, sizeof(*env));
|
||||
|
||||
// assign unique pid
|
||||
env->iPID = pid++;
|
||||
|
||||
// save console ref
|
||||
env->pConsole = console;
|
||||
|
||||
// copy command line
|
||||
ds_strnzcpy(env->strArgb, cmdline, sizeof(env->strArgb));
|
||||
s = env->strArgb;
|
||||
|
||||
// parse command line
|
||||
for (env->iArgc = 0; env->iArgc < (signed)(sizeof(env->pArgv)/sizeof(env->pArgv[0])); env->iArgc += 1)
|
||||
{
|
||||
// skip to next token
|
||||
while ((*s != 0) && (*s <= ' '))
|
||||
++s;
|
||||
// see if anything to save
|
||||
if (*s == 0)
|
||||
break;
|
||||
// see if there is a terminator
|
||||
term = ((*s == '"') || (*s == '\'') ? *s++ : 0);
|
||||
// record start of token
|
||||
env->pArgv[env->iArgc] = s;
|
||||
// find end of token
|
||||
while ((*s != 0) && (((term == 0) && (*s > ' ')) || ((term != 0) && (*s != term))))
|
||||
++s;
|
||||
// terminate token
|
||||
if (*s != 0)
|
||||
*s++ = 0;
|
||||
}
|
||||
|
||||
// set status to terminated
|
||||
env->iStatus = 0;
|
||||
env->uSchedule = (uint32_t)(-1);
|
||||
|
||||
// put into process list
|
||||
env->pNext = _pEnvList;
|
||||
_pEnvList = env;
|
||||
|
||||
// return new environment
|
||||
return(env);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZDestroy
|
||||
|
||||
\Description
|
||||
Destroy a process environment
|
||||
|
||||
\Input env - existing process environment
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZDestroy(ZEnviron *env)
|
||||
{
|
||||
ZEnviron **scan;
|
||||
|
||||
// remove from environment list
|
||||
for (scan = &_pEnvList; *scan != NULL; scan = &(*scan)->pNext)
|
||||
{
|
||||
if (*scan == env)
|
||||
{
|
||||
*scan = env->pNext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// remove from active
|
||||
if (_pEnvCurr == env)
|
||||
_pEnvCurr = NULL;
|
||||
|
||||
// destroy any attached context
|
||||
if (env->pContext != NULL)
|
||||
ZMemFree(env->pContext);
|
||||
|
||||
// destroy the environment
|
||||
ZMemFree(env);
|
||||
return;
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZInvoke
|
||||
|
||||
\Description
|
||||
Execute a process within an existing environment
|
||||
|
||||
\Input env - existing environment
|
||||
\Input cmd - process code pointer
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZInvoke(ZEnviron *env, ZCommand *cmd)
|
||||
{
|
||||
uint32_t tick1, tick2;
|
||||
|
||||
// make sure there is a current environment
|
||||
if (env == NULL)
|
||||
return;
|
||||
_pEnvCurr = env;
|
||||
|
||||
// if this is first run
|
||||
if (cmd != NULL)
|
||||
{
|
||||
// save the command
|
||||
_pEnvCurr->pCommand = cmd;
|
||||
// remove any existing context
|
||||
ZContextCreate(0);
|
||||
}
|
||||
else if (_pEnvCurr->pCommand == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// invoke the command
|
||||
tick1 = ZTick();
|
||||
_pEnvCurr->uSchedule = (uint32_t)(-1);
|
||||
_pEnvCurr->uRuncount += 1;
|
||||
_pEnvCurr->iStatus = _pEnvCurr->pCommand(_pEnvCurr->pContext, _pEnvCurr->iArgc, _pEnvCurr->pArgv);
|
||||
tick2 = ZTick();
|
||||
_pEnvCurr->uRuntime += tick2-tick1;
|
||||
|
||||
// handle callback request
|
||||
if ((_pEnvCurr->uSchedule != (uint32_t)(-1)) && (_pEnvCurr->iStatus == ZLIB_STATUS_RUNNING))
|
||||
_pEnvCurr->uSchedule += tick2;
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZSet
|
||||
|
||||
\Description
|
||||
Set current environment, based on specified context
|
||||
|
||||
\Input context - context; environment that owns this context will be made current
|
||||
|
||||
\Version 10/10/2012 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZSet(ZContext *context)
|
||||
{
|
||||
ZEnviron *env;
|
||||
|
||||
// find context
|
||||
for (env = _pEnvCurr; env != NULL && env->pContext != context; env = env->pNext)
|
||||
;
|
||||
|
||||
// found it? make it current
|
||||
if (env != NULL)
|
||||
{
|
||||
_pEnvCurr = env;
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZGetPid
|
||||
|
||||
\Description
|
||||
Get process id of current environment
|
||||
|
||||
\Output
|
||||
int32_t - pid, or zero if no current environment
|
||||
|
||||
\Version 10/10/2012 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZGetPid(void)
|
||||
{
|
||||
int32_t iPID = 0;
|
||||
if (_pEnvCurr != NULL)
|
||||
{
|
||||
iPID = _pEnvCurr->iPID;
|
||||
}
|
||||
return(iPID);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCallback
|
||||
|
||||
\Description
|
||||
Let process signal it wants a callback (has not completed)
|
||||
|
||||
\Input cmd - pointer to callback code
|
||||
\Input delay - milliseconds until callback
|
||||
|
||||
\Output int32_t - special return value that process returns with
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZCallback(ZCommand *cmd, int32_t delay)
|
||||
{
|
||||
_pEnvCurr->pCommand = cmd;
|
||||
_pEnvCurr->uSchedule = delay;
|
||||
return(ZLIB_STATUS_RUNNING);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZTask
|
||||
|
||||
\Description
|
||||
Give time to any existing processes that need it.
|
||||
|
||||
\Output int32_t - number of ticks until the next requested update
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZTask(void)
|
||||
{
|
||||
ZEnviron *env;
|
||||
uint32_t tick = ZTick();
|
||||
uint32_t next = tick+1000;
|
||||
|
||||
// walk environ list and execute processes which are scheduled
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext)
|
||||
{
|
||||
if (tick > env->uSchedule)
|
||||
ZInvoke(env, NULL);
|
||||
if (next > env->uSchedule)
|
||||
next = env->uSchedule;
|
||||
}
|
||||
|
||||
// figure time until next tick
|
||||
tick = ZTick();
|
||||
return((tick > next) ? 0 : next-tick);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCleanup
|
||||
|
||||
\Description
|
||||
Remove any environments containing complete processes.
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZCleanup(void)
|
||||
{
|
||||
ZEnviron *env;
|
||||
|
||||
for (env = _pEnvList; env != NULL;)
|
||||
{
|
||||
if (env->uSchedule == (uint32_t)(-1))
|
||||
{
|
||||
ZEnviron *kill = env;
|
||||
env = env->pNext;
|
||||
ZDestroy(kill);
|
||||
}
|
||||
else
|
||||
{
|
||||
env = env->pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZShutdown
|
||||
|
||||
\Description
|
||||
Kill all active processes in preparation for shutdown.
|
||||
|
||||
\Version 02/18/03 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZShutdown(void)
|
||||
{
|
||||
ZEnviron *env;
|
||||
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext)
|
||||
{
|
||||
// kill the process
|
||||
env->uSchedule = (uint32_t)(-1);
|
||||
env->iStatus = (env->pCommand)(env->pContext, 0, env->pArgv);
|
||||
env->uSchedule = (uint32_t)(-1);
|
||||
}
|
||||
|
||||
while(_pEnvList != NULL)
|
||||
{
|
||||
ZTask();
|
||||
ZCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCreateContext
|
||||
|
||||
\Description
|
||||
Allow a process to allocate persistent private context.
|
||||
|
||||
\Input size - size of needed context
|
||||
|
||||
\Output ZContext * - context of requested size
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
ZContext *ZContextCreate(int32_t size)
|
||||
{
|
||||
if (_pEnvCurr == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (_pEnvCurr->pContext != NULL)
|
||||
ZMemFree(_pEnvCurr->pContext);
|
||||
|
||||
_pEnvCurr->pContext = ((size > 0) ? (ZContext *)ZMemAlloc(size) : NULL);
|
||||
return(_pEnvCurr->pContext);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZPrintf
|
||||
|
||||
\Description
|
||||
Display output using standard printf semantics.
|
||||
|
||||
\Input Standard printf inputs.
|
||||
|
||||
\Version 09/15/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZPrintf(const char *fmt, ...)
|
||||
{
|
||||
char text[4096];
|
||||
va_list args;
|
||||
int32_t iOutput=1;
|
||||
|
||||
// parse the data
|
||||
va_start(args, fmt);
|
||||
ds_vsnprintf(text, sizeof(text), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// send to debug hook if set
|
||||
if (_Zlib_pPrintfHook != NULL)
|
||||
{
|
||||
iOutput = _Zlib_pPrintfHook(_Zlib_pPrintfParm, text);
|
||||
}
|
||||
|
||||
// if debug hook didn't override output, print here
|
||||
if (iOutput != 0)
|
||||
{
|
||||
#if defined(DIRTYCODE_PC) || defined(DIRTYCODE_XBOXONE) || defined(DIRTYCODE_GDK)
|
||||
OutputDebugStringA(text);
|
||||
#else
|
||||
printf("%s", text);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZPrintf2
|
||||
|
||||
\Description
|
||||
Display output using standard printf semantics (no hook).
|
||||
|
||||
\Input Standard printf inputs.
|
||||
|
||||
\Version 10/18/2011 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZPrintf2(const char *fmt, ...)
|
||||
{
|
||||
char text[4096];
|
||||
va_list args;
|
||||
|
||||
// parse the data
|
||||
va_start(args, fmt);
|
||||
ds_vsnprintf(text, sizeof(text), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// print here
|
||||
#if defined(DIRTYCODE_PC) || defined(DIRTYCODE_XBOXONE) || defined(DIRTYCODE_GDK)
|
||||
OutputDebugStringA(text);
|
||||
#else
|
||||
printf("%s", text);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZPrintfHook
|
||||
|
||||
\Description
|
||||
Hook into output.
|
||||
|
||||
\Input *pPrintfHook - pointer to function to call with output
|
||||
\Input *pParm - user parameter
|
||||
|
||||
\Output
|
||||
None.
|
||||
|
||||
\Version 03/23/2006 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZPrintfHook(int32_t (*pPrintfHook)(void *pParm, const char *pText), void *pParm)
|
||||
{
|
||||
_Zlib_pPrintfHook = pPrintfHook;
|
||||
_Zlib_pPrintfParm = pParm;
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCmdPS
|
||||
|
||||
\Description
|
||||
Show list of all process environments.
|
||||
|
||||
\Input *argz - context
|
||||
\Input argc - arg count
|
||||
\Input argz - arg strings
|
||||
|
||||
\Output int32_t - exit code
|
||||
|
||||
\Version 10/04/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZCmdPS(ZContext *argz, int32_t argc, char **pArgv)
|
||||
{
|
||||
ZEnviron *env;
|
||||
uint32_t tick = ZTick();
|
||||
|
||||
// handle help
|
||||
if (argc == 0) {
|
||||
ZPrintf("%s - show process status list\r\n", pArgv[0]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// show process status list
|
||||
ZPrintf(" PID STATUS ITER TIME COMMAND\r\n");
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext) {
|
||||
int32_t i;
|
||||
char text[256];
|
||||
char *s = text;
|
||||
|
||||
// dont show ourselves
|
||||
if (env == _pEnvCurr)
|
||||
continue;
|
||||
|
||||
// put in pid
|
||||
s += wsprintf(s, "%5d", env->iPID);
|
||||
|
||||
// add in state/time till next
|
||||
if (env->uSchedule == (uint32_t)(-1))
|
||||
{
|
||||
s += wsprintf(s, " F %4d", env->iStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t timeout = env->uSchedule-tick;
|
||||
if (timeout < 0)
|
||||
timeout = 0;
|
||||
if (timeout > 9999)
|
||||
timeout = 9999;
|
||||
s += wsprintf(s, " S %4d", timeout);
|
||||
}
|
||||
|
||||
// show run count
|
||||
s += wsprintf(s, " %4d", (env->uRuncount < 9999 ? env->uRuncount : 9999));
|
||||
|
||||
// show time used
|
||||
s += wsprintf(s, " %2d.%03d", env->uRuntime/1000, env->uRuntime%1000);
|
||||
|
||||
// show command name
|
||||
s += wsprintf(s, " %s", env->pArgv[0]);
|
||||
|
||||
// show command parms
|
||||
for (i = 1; i < env->iArgc; ++i)
|
||||
s += wsprintf(s, " '%s'", env->pArgv[i]);
|
||||
|
||||
// end of line
|
||||
*s++ = '\r';
|
||||
*s++ = '\n';
|
||||
*s = 0;
|
||||
ZPrintf("%s", text);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZCmdKill
|
||||
|
||||
\Description
|
||||
Kill an existing process.
|
||||
|
||||
\Input *argz - context
|
||||
\Input argc - arg count
|
||||
\Input argz - arg strings
|
||||
|
||||
\Output int32_t - exit code
|
||||
|
||||
\Version 10/04/1999 (gschaefer)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZCmdKill(ZContext *argz, int32_t argc, char **pArgv)
|
||||
{
|
||||
int32_t pid;
|
||||
char *s, *d;
|
||||
ZEnviron *env;
|
||||
|
||||
// handle help
|
||||
if (argc == 0) {
|
||||
ZPrintf("%s pid|name - kill a running command\r\n", pArgv[0]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// check usage
|
||||
if (argc != 2) {
|
||||
ZPrintf("usage: %s pid|name\r\n", pArgv[0]);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// get the pid
|
||||
pid = 0;
|
||||
for (s = pArgv[1]; (*s >= '0') && (*s <= '9'); ++s)
|
||||
pid = (pid * 10) + (*s & 15);
|
||||
|
||||
// if its zero, see if the name matches
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext)
|
||||
{
|
||||
for (s = pArgv[1], d = env->pArgv[0]; *s != 0; ++s, ++d)
|
||||
{
|
||||
if (*s != *d)
|
||||
break;
|
||||
}
|
||||
if (*s == 0)
|
||||
{
|
||||
pid = env->iPID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we got something
|
||||
if (pid <= 0)
|
||||
{
|
||||
ZPrintf("%s: invalid pid: %s\r\n", pArgv[0], pArgv[1]);
|
||||
return(-2);
|
||||
}
|
||||
|
||||
// search process list for match
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext) {
|
||||
if ((env != _pEnvCurr) && (env->iPID == pid))
|
||||
break;
|
||||
}
|
||||
|
||||
// error if no matching process
|
||||
if (env == NULL)
|
||||
{
|
||||
ZPrintf("%s: no such process %d\r\n", pArgv[0], pid);
|
||||
return(-3);
|
||||
}
|
||||
|
||||
// if already dead
|
||||
if (env->uSchedule == (uint32_t)(-1))
|
||||
{
|
||||
ZPrintf("%s: process %d already dead\r\n", pArgv[0], pid);
|
||||
return(-4);
|
||||
}
|
||||
|
||||
// kill the process
|
||||
env->uSchedule = (uint32_t)(-1);
|
||||
env->iStatus = (env->pCommand)(env->pContext, 0, env->pArgv);
|
||||
env->uSchedule = (uint32_t)(-1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZGetStatus
|
||||
|
||||
\Description
|
||||
Return status of current command. Returns -1 if pEnv is Null.
|
||||
|
||||
\Input pEnv -pointer to current env, command.
|
||||
|
||||
\Output Status of current command. Returns -1 if pEnv is Null.
|
||||
|
||||
\Version 29/11/2005 (TE)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZGetStatus(ZEnviron *pEnv)
|
||||
{
|
||||
return(pEnv ? pEnv->iStatus :-1);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZGetStatusPid
|
||||
|
||||
\Description
|
||||
Get status of the process specified by pid
|
||||
|
||||
\Output
|
||||
int32_t - status, or ZLIB_STATUS_UNKNOWN if process is not found
|
||||
|
||||
\Version 10/10/2012 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZGetStatusPid(int32_t iPID)
|
||||
{
|
||||
ZEnviron *env;
|
||||
|
||||
// show process status list
|
||||
for (env = _pEnvList; env != NULL; env = env->pNext)
|
||||
{
|
||||
if (env->iPID == iPID)
|
||||
{
|
||||
return(env->iStatus);
|
||||
}
|
||||
}
|
||||
return(ZLIB_STATUS_UNKNOWN);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZGetIntArg
|
||||
|
||||
\Description
|
||||
Get fourcc/integer from command-line argument
|
||||
|
||||
\Input *pArg - pointer to argument
|
||||
|
||||
\Version 11/26/2018 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZGetIntArg(const char *pArg)
|
||||
{
|
||||
int32_t iValue;
|
||||
|
||||
// check for possible fourcc value
|
||||
if ((strlen(pArg) == 4) && (isalpha(pArg[0]) || isalpha(pArg[1]) || isalpha(pArg[2]) || isalpha(pArg[3])))
|
||||
{
|
||||
iValue = pArg[0] << 24;
|
||||
iValue |= pArg[1] << 16;
|
||||
iValue |= pArg[2] << 8;
|
||||
iValue |= pArg[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
iValue = (signed)strtol(pArg, NULL, 10);
|
||||
}
|
||||
return(iValue);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function ZTick
|
||||
|
||||
\Description
|
||||
Return some kind of increasing tick count with millisecond scale (does
|
||||
not need to have millisecond precision, but higher precision is better).
|
||||
|
||||
\Output
|
||||
uint32_t - millisecond tick count
|
||||
|
||||
\Version 1.0 05/06/2005 (jfrank) First Version
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
uint32_t ZTick(void)
|
||||
{
|
||||
return(NetTick());
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZSleep
|
||||
|
||||
\Description
|
||||
Put process to sleep for some period of time
|
||||
|
||||
\Input uMSecs - Number of milliseconds to sleep for.
|
||||
|
||||
\Version 05/06/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZSleep(uint32_t uMSecs)
|
||||
{
|
||||
NetConnSleep(uMSecs);
|
||||
}
|
||||
|
||||
|
||||
|
270
src/thirdparty/dirtysdk/contrib/common/source/zlist.c
vendored
Normal file
270
src/thirdparty/dirtysdk/contrib/common/source/zlist.c
vendored
Normal file
@ -0,0 +1,270 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zlist.h
|
||||
|
||||
\Description
|
||||
Generic list module for samples to use.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 04/26/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/dirtysock.h"
|
||||
#include "zmem.h"
|
||||
#include "zlib.h"
|
||||
#include "zlist.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
struct ZListT
|
||||
{
|
||||
uint32_t iNumEntries; //!< number of entries in the list
|
||||
uint32_t iEntrySize; //!< size of each entry
|
||||
uint32_t uHead; //!< index of input list head entry
|
||||
uint32_t uTail; //!< index of input list tail entry
|
||||
void *pData; //!< data
|
||||
};
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListCreate
|
||||
|
||||
\Description
|
||||
Create a list object
|
||||
|
||||
\Input iMaxEntries - maximum number of entries in the list
|
||||
\Input iEntrySize - maximum size of each entry in the list
|
||||
|
||||
\Output ZListT * - pointer to the created list
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
ZListT *ZListCreate(int32_t iNumEntries, int32_t iEntrySize)
|
||||
{
|
||||
ZListT *pList;
|
||||
|
||||
// check for errors
|
||||
if((iNumEntries <= 0) || (iEntrySize <= 0))
|
||||
{
|
||||
ZPrintf("Could not create list with [%d] entries of size [%d] total size [%d]\n",
|
||||
iNumEntries, iEntrySize, iNumEntries * iEntrySize);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// create the list
|
||||
pList = (ZListT *)ZMemAlloc(sizeof(ZListT));
|
||||
ds_memclr(pList, sizeof(*pList));
|
||||
pList->iEntrySize = iEntrySize;
|
||||
pList->iNumEntries = iNumEntries;
|
||||
pList->pData = (ZListT *)ZMemAlloc(iNumEntries * iEntrySize);
|
||||
return(pList);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListPushBack
|
||||
|
||||
\Description
|
||||
Add and entry to the back of a data list
|
||||
|
||||
\Input pList - pointer to the list to use
|
||||
\Input pEntry - entry to add (will be copied in)
|
||||
|
||||
\Output int32_t - 0 for success, error code otherwise
|
||||
|
||||
\TODO
|
||||
The current implementation doesn't wrap the queue, so if the head
|
||||
starts chasing the tail but doesn't catch up, a large amount of the
|
||||
buffer space can end up being wasted. Either the queue needs to be
|
||||
modified to wrap, or the buffer memory shifted to allow the head to
|
||||
be reset to zero without catching the tail.
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZListPushBack(ZListT *pList, void *pEntry)
|
||||
{
|
||||
char *pDest;
|
||||
|
||||
// check to make sure we got an entry
|
||||
if ((pEntry == NULL) || (pList == NULL))
|
||||
{
|
||||
return(ZLIST_ERROR_NULLPOINTER);
|
||||
}
|
||||
|
||||
// see if the list is full
|
||||
if (pList->uTail >= pList->iNumEntries)
|
||||
{
|
||||
return(ZLIST_ERROR_FULL);
|
||||
}
|
||||
|
||||
// insert into the list
|
||||
pDest = (char *)pList->pData + (pList->uTail * pList->iEntrySize);
|
||||
ds_memcpy(pDest, pEntry, pList->iEntrySize);
|
||||
// increment the tail pointer
|
||||
pList->uTail++;
|
||||
|
||||
// done
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListPopFront
|
||||
|
||||
\Description
|
||||
Get an entry off the front of a data list
|
||||
|
||||
\Input pList - pointer to the list to destroy
|
||||
\Input pEntry - destination for the entry to get (will be copied in), NULL to discard data
|
||||
|
||||
\Output int32_t - <0 for error, 0 for no data left, >0 for amount of data left
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
int32_t ZListPopFront(ZListT *pList, void *pEntry)
|
||||
{
|
||||
uint32_t uAmtLeft;
|
||||
char *pSrc;
|
||||
|
||||
// check to make sure we got an entry
|
||||
if (pList == NULL)
|
||||
{
|
||||
return(ZLIST_ERROR_NULLPOINTER);
|
||||
}
|
||||
|
||||
// see if the list is empty
|
||||
uAmtLeft = pList->uTail - pList->uHead;
|
||||
if (uAmtLeft == 0)
|
||||
{
|
||||
// no error - list is just empty
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// only copy data if we have a container for it
|
||||
if (pEntry)
|
||||
{
|
||||
// copy from the list into the new location
|
||||
pSrc = (char *)pList->pData + (pList->uHead * pList->iEntrySize);
|
||||
ds_memcpy(pEntry, (void *)pSrc, pList->iEntrySize);
|
||||
}
|
||||
pList->uHead++;
|
||||
// test for empty list situation
|
||||
if (pList->uHead == pList->uTail)
|
||||
{
|
||||
// empty list - reset
|
||||
pList->uHead = 0;
|
||||
pList->uTail = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// done
|
||||
return(uAmtLeft);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListPeekFront
|
||||
|
||||
\Description
|
||||
Examine the front entry of a data list
|
||||
|
||||
\Input pList - pointer to the list to destroy
|
||||
|
||||
\Output void * - pointer to the first entry, NULL if empty
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void *ZListPeekFront(ZListT *pList)
|
||||
{
|
||||
char *pSrc;
|
||||
|
||||
// check for errors
|
||||
if(pList == NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// if list is empty, return NULL
|
||||
if (pList->uHead == pList->uTail)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// otherwise return a pointer to the data in question
|
||||
pSrc = (char *)pList->pData + (pList->uHead * pList->iEntrySize);
|
||||
return(pSrc);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListClear
|
||||
|
||||
\Description
|
||||
Clear the entire list
|
||||
|
||||
\Input pList - pointer to the list to destroy
|
||||
|
||||
\Output None
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZListClear(ZListT *pList)
|
||||
{
|
||||
if(pList)
|
||||
{
|
||||
ds_memclr(pList->pData, pList->iNumEntries * pList->iEntrySize);
|
||||
pList->uHead = 0;
|
||||
pList->uTail = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZListDestroy
|
||||
|
||||
\Description
|
||||
Destroy a list object and free all associated memory
|
||||
|
||||
\Input pList - pointer to the list to destroy
|
||||
|
||||
\Output None
|
||||
|
||||
\Version 04/26/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZListDestroy(ZListT *pList)
|
||||
{
|
||||
if (pList)
|
||||
{
|
||||
if (pList->pData)
|
||||
{
|
||||
ZMemFree(pList->pData);
|
||||
}
|
||||
|
||||
ZMemFree(pList);
|
||||
}
|
||||
}
|
||||
|
83
src/thirdparty/dirtysdk/contrib/common/source/zmem.c
vendored
Normal file
83
src/thirdparty/dirtysdk/contrib/common/source/zmem.c
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zmem.c
|
||||
|
||||
\Description
|
||||
Memory implementations for use on all platforms.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 03/16/2005 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock.h"
|
||||
|
||||
#include "zmemtrack.h"
|
||||
#include "zmem.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemAlloc
|
||||
|
||||
\Description
|
||||
Allocate some memory
|
||||
|
||||
\Input uSize - amount of memory, in bytes, to allocate
|
||||
|
||||
\Output void * - pointer to an allocated memory chunk
|
||||
|
||||
\Version 03/16/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void *ZMemAlloc(uint32_t uSize)
|
||||
{
|
||||
void *pMem;
|
||||
if ((pMem = (void *)malloc(uSize)) != NULL)
|
||||
{
|
||||
ds_memset(pMem, 0xCD, uSize);
|
||||
ZMemtrackAlloc(pMem, uSize, 0);
|
||||
}
|
||||
return(pMem);
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemFree
|
||||
|
||||
\Description
|
||||
Free a previously allocated chunk of memory
|
||||
|
||||
\Input void *pMem - pointer to an allocated memory chunk
|
||||
|
||||
\Output None
|
||||
|
||||
\Version 03/16/2005 (jfrank)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
uint32_t ZMemFree(void *pMem)
|
||||
{
|
||||
uint32_t uSize;
|
||||
ZMemtrackFree(pMem, &uSize);
|
||||
ds_memset(pMem, 0xEF, uSize);
|
||||
free(pMem);
|
||||
return(uSize);
|
||||
}
|
371
src/thirdparty/dirtysdk/contrib/common/source/zmemtrack.c
vendored
Normal file
371
src/thirdparty/dirtysdk/contrib/common/source/zmemtrack.c
vendored
Normal file
@ -0,0 +1,371 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File zmemtrack.c
|
||||
|
||||
\Description
|
||||
Routines for tracking memory allocations.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005-2017 Electronic Arts Inc.
|
||||
|
||||
\Version 02/15/2005 (jbrookes) First Version, based on jfrank's implementation.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "zlib.h"
|
||||
#include "zmem.h"
|
||||
#include "zmemtrack.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define ZMEMTRACK_MEMDUMPBYTES (64) //!< number of bytes to print around the leak
|
||||
#define ZMEMTRACK_MAXALLOCATIONS (1024*8) //!< maximum list allocation size
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct ZMemtrackElemT
|
||||
{
|
||||
void *pMem;
|
||||
uint32_t uMemSize;
|
||||
uint32_t uTag;
|
||||
} ZMemtrackElemT;
|
||||
|
||||
typedef struct ZMemtrackRefT
|
||||
{
|
||||
uint32_t uNumAllocations;
|
||||
uint32_t uMaxAllocations;
|
||||
uint32_t uTotalAllocations;
|
||||
uint32_t uTotalMemory;
|
||||
uint32_t uMaxMemory;
|
||||
uint8_t bOverflow;
|
||||
uint8_t bStarted;
|
||||
uint8_t _pad[2];
|
||||
|
||||
ZMemtrackLogCbT *pLoggingCb;
|
||||
void *pUserData;
|
||||
|
||||
ZMemtrackElemT MemList[ZMEMTRACK_MAXALLOCATIONS];
|
||||
} ZMemtrackRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
static ZMemtrackRefT _ZMemtrack_Ref;
|
||||
|
||||
/*** Private Functions ************************************************************/
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function _ZMemtrackLogPrintf
|
||||
|
||||
\Description
|
||||
Logs the information from the module
|
||||
|
||||
\Input *pFormat - information to log
|
||||
\Input ... - additional parameters
|
||||
|
||||
\Version 09/18/2017 (eesponda)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
static void _ZMemtrackLogPrintf(const char *pFormat, ...)
|
||||
{
|
||||
char strText[2048];
|
||||
int32_t iOffset = 0;
|
||||
va_list Args;
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
|
||||
// format output
|
||||
va_start(Args, pFormat);
|
||||
iOffset += ds_vsnprintf(strText+iOffset, sizeof(strText)-iOffset, pFormat, Args);
|
||||
va_end(Args);
|
||||
|
||||
// forward to callback, or print if not callback installed
|
||||
if (pRef->pLoggingCb != NULL)
|
||||
{
|
||||
pRef->pLoggingCb(strText, pRef->pUserData);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZPrintf("zmemtrack: %s", strText);
|
||||
}
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function _ZMemtrackPrintLeak
|
||||
|
||||
\Description
|
||||
Print a memory leak to debug output.
|
||||
|
||||
\Input *pElem - pointer to allocation that was leaked
|
||||
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
static void _ZMemtrackPrintLeak(ZMemtrackElemT *pElem)
|
||||
{
|
||||
static const char _hex[] = "0123456789ABCDEF";
|
||||
uint32_t uBytes;
|
||||
char strOutput[128];
|
||||
int32_t iOutput = 2;
|
||||
|
||||
_ZMemtrackLogPrintf("allocated: [%d] bytes at [%p] with tag '%c%c%c%c'\n", pElem->uMemSize, pElem->pMem,
|
||||
(uint8_t)(pElem->uTag>>24), (uint8_t)(pElem->uTag>>16), (uint8_t)(pElem->uTag>>8), (uint8_t)(pElem->uTag));
|
||||
|
||||
ds_memset(strOutput, ' ', sizeof(strOutput)-1);
|
||||
strOutput[sizeof(strOutput)-1] = '\0';
|
||||
|
||||
for (uBytes = 0; (uBytes < pElem->uMemSize) && (uBytes < ZMEMTRACK_MEMDUMPBYTES); uBytes++, iOutput += 2)
|
||||
{
|
||||
unsigned char cByte = ((unsigned char *)(pElem->pMem))[uBytes];
|
||||
strOutput[iOutput] = _hex[cByte>>4];
|
||||
strOutput[iOutput+1] = _hex[cByte&0xf];
|
||||
strOutput[(iOutput/2)+40] = isprint(cByte) ? cByte : '.';
|
||||
if (uBytes > 0)
|
||||
{
|
||||
if (((uBytes+1) % 16) == 0)
|
||||
{
|
||||
strOutput[(iOutput/2)+40+1] = '\0';
|
||||
_ZMemtrackLogPrintf("%s\n", strOutput);
|
||||
ds_memset(strOutput, ' ', sizeof(strOutput)-1);
|
||||
strOutput[sizeof(strOutput)-1] = '\0';
|
||||
iOutput = 0;
|
||||
}
|
||||
else if (((uBytes+1) % 4) == 0)
|
||||
{
|
||||
iOutput++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((uBytes > ZMEMTRACK_MEMDUMPBYTES) && (uBytes % ZMEMTRACK_MEMDUMPBYTES) != 0) || (pElem->uMemSize < 16))
|
||||
{
|
||||
strOutput[(iOutput/2)+40+1] = '\0';
|
||||
_ZMemtrackLogPrintf("%s\n", strOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Public functions *************************************************************/
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackStartup
|
||||
|
||||
\Description
|
||||
Start up the ZMemtracking module.
|
||||
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackStartup(void)
|
||||
{
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
ds_memclr(pRef, sizeof(*pRef));
|
||||
pRef->bStarted = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackShutdown
|
||||
|
||||
\Description
|
||||
Shut down the ZMemtracking module.
|
||||
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackShutdown(void)
|
||||
{
|
||||
// dump the current status of the entire module
|
||||
ZMemtrackPrint(ZMEMTRACK_PRINTFLAG_TRACKING, 0, NULL);
|
||||
_ZMemtrack_Ref.bStarted = FALSE;
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackCallback
|
||||
|
||||
\Description
|
||||
Set the logging callback
|
||||
|
||||
\Input *pLoggingCb - logging function pointer
|
||||
\Input *pUserData - additional data to pass along
|
||||
|
||||
\Version 09/18/2017 (eesponda)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackCallback(ZMemtrackLogCbT *pLoggingCb, void *pUserData)
|
||||
{
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
pRef->pLoggingCb = pLoggingCb;
|
||||
pRef->pUserData = pUserData;
|
||||
}
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackAlloc
|
||||
|
||||
\Description
|
||||
Track an allocation.
|
||||
|
||||
\Input *pMem - pointer to allocated memory block
|
||||
\Input uSize - size of allocated memory block
|
||||
\Input uTag - allocation tag
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackAlloc(void *pMem, uint32_t uSize, uint32_t uTag)
|
||||
{
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
uint32_t uMemEntry;
|
||||
|
||||
// now if we got the memory, add to the list
|
||||
if ((pMem == NULL) || (pRef->bStarted == FALSE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// find a clear spot
|
||||
for (uMemEntry = 0; uMemEntry < ZMEMTRACK_MAXALLOCATIONS; uMemEntry++)
|
||||
{
|
||||
if (pRef->MemList[uMemEntry].pMem == NULL)
|
||||
{
|
||||
// get the memory location
|
||||
pRef->uTotalMemory += uSize;
|
||||
pRef->uNumAllocations += 1;
|
||||
pRef->uTotalAllocations += 1;
|
||||
|
||||
// update high-water tracking
|
||||
if (pRef->uMaxAllocations < pRef->uNumAllocations)
|
||||
{
|
||||
pRef->uMaxAllocations = pRef->uNumAllocations;
|
||||
}
|
||||
if (pRef->uMaxMemory < pRef->uTotalMemory)
|
||||
{
|
||||
pRef->uMaxMemory = pRef->uTotalMemory;
|
||||
}
|
||||
|
||||
// store the info
|
||||
pRef->MemList[uMemEntry].pMem = pMem;
|
||||
pRef->MemList[uMemEntry].uMemSize = uSize;
|
||||
pRef->MemList[uMemEntry].uTag = uTag;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check to see if we ran out of room to store this stuff
|
||||
if (uMemEntry == ZMEMTRACK_MAXALLOCATIONS)
|
||||
{
|
||||
pRef->bOverflow = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackFree
|
||||
|
||||
\Description
|
||||
Track a free operation.
|
||||
|
||||
\Input *pMem - pointer to allocated memory block
|
||||
\Input *pSize - [out] storage for memory block size
|
||||
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackFree(void *pMem, uint32_t *pSize)
|
||||
{
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
uint32_t uMemEntry;
|
||||
|
||||
if ((pMem == NULL) || (pRef->bStarted == FALSE))
|
||||
{
|
||||
*pSize = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (uMemEntry = 0, *pSize = 0; uMemEntry < ZMEMTRACK_MAXALLOCATIONS; uMemEntry++)
|
||||
{
|
||||
if (pRef->MemList[uMemEntry].pMem == pMem)
|
||||
{
|
||||
pRef->uTotalMemory -= pRef->MemList[uMemEntry].uMemSize;
|
||||
pRef->uNumAllocations -= 1;
|
||||
*pSize = pRef->MemList[uMemEntry].uMemSize;
|
||||
ds_memclr(&pRef->MemList[uMemEntry], sizeof(pRef->MemList[uMemEntry]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*F********************************************************************************/
|
||||
/*!
|
||||
\Function ZMemtrackPrint
|
||||
|
||||
\Description
|
||||
Print overall memory info.
|
||||
|
||||
\Input uFlags - ZMemtrack_PRINTFLAG_*
|
||||
\Input uTag - [optional] if non-zero, only display memory leaks stamped with this tag
|
||||
\Input *pModuleName - [optional] pointer to module name
|
||||
|
||||
\Version 02/15/2005 (jbrookes)
|
||||
*/
|
||||
/********************************************************************************F*/
|
||||
void ZMemtrackPrint(uint32_t uFlags, uint32_t uTag, const char *pModuleName)
|
||||
{
|
||||
ZMemtrackRefT *pRef = &_ZMemtrack_Ref;
|
||||
uint32_t uMemEntry;
|
||||
|
||||
if (uFlags & ZMEMTRACK_PRINTFLAG_TRACKING)
|
||||
{
|
||||
_ZMemtrackLogPrintf("memory report\n");
|
||||
_ZMemtrackLogPrintf(" maximum number of allocations at once: [%u]\n", pRef->uMaxAllocations);
|
||||
_ZMemtrackLogPrintf(" current number of allocations : [%u]\n", pRef->uNumAllocations);
|
||||
_ZMemtrackLogPrintf(" total number of allocations ever : [%u]\n", pRef->uTotalAllocations);
|
||||
_ZMemtrackLogPrintf(" maximum memory allocated : [%u] bytes\n", pRef->uMaxMemory);
|
||||
_ZMemtrackLogPrintf(" current memory allocated : [%u] bytes\n", pRef->uTotalMemory);
|
||||
_ZMemtrackLogPrintf("\n");
|
||||
}
|
||||
|
||||
if (pRef->bOverflow)
|
||||
{
|
||||
_ZMemtrackLogPrintf("WARNING: Allocation watcher overflowed!");
|
||||
}
|
||||
|
||||
// see if there were any leaks
|
||||
for (uMemEntry = 0; uMemEntry < ZMEMTRACK_MAXALLOCATIONS; uMemEntry++)
|
||||
{
|
||||
ZMemtrackElemT *pElem = &pRef->MemList[uMemEntry];
|
||||
if ((pElem->pMem != NULL) && ((uTag == 0) || (pElem->uTag == uTag)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if there were leaks, display them
|
||||
if (uMemEntry != ZMEMTRACK_MAXALLOCATIONS)
|
||||
{
|
||||
_ZMemtrackLogPrintf("detected %s memory leaks!\n", pModuleName != NULL ? pModuleName : "");
|
||||
for ( ; uMemEntry < ZMEMTRACK_MAXALLOCATIONS; uMemEntry++)
|
||||
{
|
||||
ZMemtrackElemT *pElem = &pRef->MemList[uMemEntry];
|
||||
if ((pElem->pMem != NULL) && ((uTag == 0) || (pElem->uTag == uTag)))
|
||||
{
|
||||
_ZMemtrackPrintLeak(pElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
src/thirdparty/dirtysdk/contrib/voipaux/include/voipaux/voipopus.h
vendored
Normal file
36
src/thirdparty/dirtysdk/contrib/voipaux/include/voipaux/voipopus.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File voipopus.c
|
||||
|
||||
\Description
|
||||
PC Audio Encoder / Decoder using Opus
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _voipopus_h
|
||||
#define _voipopus_h
|
||||
|
||||
/*** Includes **************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/voip/voipcodec.h"
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// opus codec definition
|
||||
DIRTYCODE_API extern const VoipCodecDefT VoipOpus_CodecDef;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _voipopus_h
|
46
src/thirdparty/dirtysdk/contrib/voipaux/include/voipaux/voipspeex.h
vendored
Normal file
46
src/thirdparty/dirtysdk/contrib/voipaux/include/voipaux/voipspeex.h
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File voipspeex.h
|
||||
|
||||
\Description
|
||||
PC Audio Encoder / Decoder using Speex
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2007. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 04/02/2007 (cadam) First version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _voipspeex_h
|
||||
#define _voipspeex_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtymem.h"
|
||||
#include "DirtySDK/voip/voipcodec.h"
|
||||
#include "DirtySDK/voip/voip.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// speex codec definition
|
||||
DIRTYCODE_API extern const VoipCodecDefT VoipSpeex_CodecDef;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _voipspeex_h
|
582
src/thirdparty/dirtysdk/contrib/voipaux/source/voipopus.c
vendored
Normal file
582
src/thirdparty/dirtysdk/contrib/voipaux/source/voipopus.c
vendored
Normal file
@ -0,0 +1,582 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File voipopus.c
|
||||
|
||||
\Description
|
||||
PC Audio Encoder / Decoder using Opus
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017. ALL RIGHTS RESERVED.
|
||||
|
||||
\Notes
|
||||
We depend on the Speex resampler for resampling (recommended by Opus)
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/dirtysock.h"
|
||||
|
||||
#include <opus.h>
|
||||
#include <speex/speex_resampler.h>
|
||||
|
||||
#include "DirtySDK/dirtysock/dirtyerr.h"
|
||||
#include "DirtySDK/dirtysock/dirtymem.h"
|
||||
#include "DirtySDK/voip/voip.h"
|
||||
#include "voipopus.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! maximum duration frame
|
||||
#define VOIPOPUS_MAX_FRAME (5760)
|
||||
|
||||
//! sampling rate we support in Hz
|
||||
#if !defined(VOIPOPUS_DEFAULT_SAMPLING_RATE)
|
||||
#define VOIPOPUS_DEFAULT_SAMPLING_RATE (16000)
|
||||
#endif
|
||||
|
||||
//! duration of the frame in milliseconds; 20ms
|
||||
#define VOIPOPUS_FRAMEDURATION (20)
|
||||
|
||||
//! number of channels we support (mono or stereo)
|
||||
#define VOIPOPUS_DEFAULT_CHANNELS (1)
|
||||
|
||||
//! hard-coded maximum output used when encoding, this is taken from value in voippacket.h (VOIP_MAXMICRPKTSIZE)
|
||||
#define VOIPOPUS_MAX_OUTPUT (1238)
|
||||
|
||||
//! speex resampler quality value (it is a number from 1 - 10)
|
||||
#define VOIPOPUS_RESAMPLER_QUALITY (3)
|
||||
|
||||
//! this much space will be needed to resample 20ms of audio
|
||||
#define VOIPOPUS_RESAMPLE_BUFFER_SIZE ((VOIPOPUS_FRAMEDURATION * VOIPOPUS_DEFAULT_SAMPLING_RATE * sizeof(float)) / 1000)
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
//! calculate the sample rate based on number of samples
|
||||
#define VOIPOPUS_GetSampleRate(uNumSamples) (((uNumSamples) * 1000) / VOIPOPUS_FRAMEDURATION)
|
||||
|
||||
/*** Type Definition *******************************************************************/
|
||||
|
||||
//! voipopus module state
|
||||
typedef struct VoipOpusRefT
|
||||
{
|
||||
VoipCodecRefT CodecState;
|
||||
|
||||
int32_t iMemGroup; //!< memgroup id
|
||||
void *pMemGroupUserData; //!< memgroup userdata
|
||||
|
||||
int32_t iVerbose; //!< logging verbosity level
|
||||
int32_t iOutputVolume; //!< volumn configuration
|
||||
|
||||
uint32_t uSampleRateIn; //!< what is the sample rate of the data being passed to encode
|
||||
uint32_t uResamplerRate; //!< sample rate that our resampler is configured to. this allows us to switch the resampler on and off without reallocation
|
||||
uint8_t bInt32Input; //!< is the input data coming as 32 bit integers
|
||||
uint8_t bFloatInput; //!< is the input data coming as 32 bit floats
|
||||
uint8_t _pad[2];
|
||||
|
||||
SpeexResamplerState *pSpeexResampler; //!< resampler used if sample rate != VOIPOPUS_DEFAULT_SAMPLING_RATE
|
||||
OpusEncoder *pEncoder; //!< opus encoder
|
||||
OpusDecoder *aDecoders[1]; //!< opus variable decoders (must come last!)
|
||||
} VoipOpusRefT;
|
||||
|
||||
/*** Function Prototypes ***************************************************************/
|
||||
|
||||
static VoipCodecRefT *_VoipOpusCreate(int32_t iNumDecoders);
|
||||
static void _VoipOpusDestroy(VoipCodecRefT *pState);
|
||||
static int32_t _VoipOpusEncodeBlock(VoipCodecRefT *pState, uint8_t *pOutput, const int16_t *pInput, int32_t iNumSamples);
|
||||
static int32_t _VoipOpusDecodeBlock(VoipCodecRefT *pState, int32_t *pOutput, const uint8_t *pInput, int32_t iInputBytes, int32_t iChannel);
|
||||
static void _VoipOpusReset(VoipCodecRefT *pState);
|
||||
static int32_t _VoipOpusControl(VoipCodecRefT *pState, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
static int32_t _VoipOpusStatus(VoipCodecRefT *pState, int32_t iSelect, int32_t iValue, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
//! voipopus codec definition
|
||||
const VoipCodecDefT VoipOpus_CodecDef =
|
||||
{
|
||||
_VoipOpusCreate,
|
||||
_VoipOpusDestroy,
|
||||
_VoipOpusEncodeBlock,
|
||||
_VoipOpusDecodeBlock,
|
||||
_VoipOpusReset,
|
||||
_VoipOpusControl,
|
||||
_VoipOpusStatus
|
||||
};
|
||||
|
||||
#if DIRTYSOCK_ERRORNAMES
|
||||
//! errors returned from the opus api
|
||||
static const DirtyErrT _VoipOpus_aErrList[] =
|
||||
{
|
||||
DIRTYSOCK_ErrorName(OPUS_OK), // 0; No Error
|
||||
DIRTYSOCK_ErrorName(OPUS_BAD_ARG), // -1; One of more invalid/out of range arguments
|
||||
DIRTYSOCK_ErrorName(OPUS_BUFFER_TOO_SMALL), // -2; The mode struct passed is invalid
|
||||
DIRTYSOCK_ErrorName(OPUS_INTERNAL_ERROR), // -3; An internal error was detected
|
||||
DIRTYSOCK_ErrorName(OPUS_INVALID_PACKET), // -4; The compressed data passed is corrupted
|
||||
DIRTYSOCK_ErrorName(OPUS_UNIMPLEMENTED), // -5; Invalid/unsupported request number
|
||||
DIRTYSOCK_ErrorName(OPUS_INVALID_STATE), // -6; An encoder or decoder structure is invalid or already freed
|
||||
DIRTYSOCK_ErrorName(OPUS_ALLOC_FAIL), // -7; Memory allocation has failed
|
||||
DIRTYSOCK_ListEnd()
|
||||
};
|
||||
#endif
|
||||
|
||||
/*** Private Functions *****************************************************************/
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusCreate
|
||||
|
||||
\Description
|
||||
Create a Opus codec state.
|
||||
|
||||
\Input iNumDecoders - number of decoder channels
|
||||
|
||||
\Output
|
||||
VoipCodecStateT * - pointer to opus codec state
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static VoipCodecRefT *_VoipOpusCreate(int32_t iNumDecoders)
|
||||
{
|
||||
VoipOpusRefT *pState;
|
||||
int32_t iResult, iMemGroup, iDecoder, iMemSize;
|
||||
void *pMemGroupUserData;
|
||||
|
||||
// query memgroup information
|
||||
iMemGroup = VoipStatus(NULL, 'mgrp', 0, NULL, 0);
|
||||
VoipStatus(NULL, 'mgud', 0, &pMemGroupUserData, sizeof(pMemGroupUserData));
|
||||
|
||||
// allocate and initialize module state
|
||||
iMemSize = sizeof(*pState) + (sizeof(OpusDecoder *) * (iNumDecoders - 1));
|
||||
if ((pState = (VoipOpusRefT *)DirtyMemAlloc(iMemSize, VOIP_MEMID, iMemGroup, pMemGroupUserData)) == NULL)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to allocate module state\n"));
|
||||
return(NULL);
|
||||
}
|
||||
ds_memclr(pState, iMemSize);
|
||||
pState->CodecState.pCodecDef = &VoipOpus_CodecDef;
|
||||
pState->CodecState.iDecodeChannels = iNumDecoders;
|
||||
pState->CodecState.bVadEnabled = TRUE;
|
||||
pState->iMemGroup = iMemGroup;
|
||||
pState->pMemGroupUserData = pMemGroupUserData;
|
||||
pState->iVerbose = 2;
|
||||
pState->iOutputVolume = 1 << VOIP_CODEC_OUTPUT_FRACTIONAL;
|
||||
|
||||
// allocate and initialize the encoder
|
||||
if ((iMemSize = opus_encoder_get_size(VOIPOPUS_DEFAULT_CHANNELS)) <= 0)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to get encoder size for allocation\n"));
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
if ((pState->pEncoder = (OpusEncoder *)DirtyMemAlloc(iMemSize, VOIP_MEMID, iMemGroup, pMemGroupUserData)) == NULL)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to allocate the encoder\n"));
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
if ((iResult = opus_encoder_init(pState->pEncoder, VOIPOPUS_DEFAULT_SAMPLING_RATE, VOIPOPUS_DEFAULT_CHANNELS, OPUS_APPLICATION_VOIP)) != OPUS_OK)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to initialize the encoder (err=%s)\n", DirtyErrGetNameList(iResult, _VoipOpus_aErrList)));
|
||||
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
// allocate and initialize the decoders
|
||||
if ((iMemSize = opus_decoder_get_size(VOIPOPUS_DEFAULT_CHANNELS)) <= 0)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to get decoder size for allocation\n"));
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
for (iDecoder = 0; iDecoder < iNumDecoders; iDecoder += 1)
|
||||
{
|
||||
if ((pState->aDecoders[iDecoder] = (OpusDecoder *)DirtyMemAlloc(iMemSize, VOIP_MEMID, iMemGroup, pMemGroupUserData)) == NULL)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to allocate the decoder\n"));
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
if ((iResult = opus_decoder_init(pState->aDecoders[iDecoder], VOIPOPUS_DEFAULT_SAMPLING_RATE, VOIPOPUS_DEFAULT_CHANNELS)) != OPUS_OK)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to initialize the decoder (err=%s)\n", DirtyErrGetNameList(iResult, _VoipOpus_aErrList)));
|
||||
_VoipOpusDestroy(&pState->CodecState);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
return(&pState->CodecState);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusDestroy
|
||||
|
||||
\Description
|
||||
Destroy the Opus codec state
|
||||
|
||||
\Input *pState - codec state
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static void _VoipOpusDestroy(VoipCodecRefT *pState)
|
||||
{
|
||||
OpusDecoder **pDecoder;
|
||||
int32_t iDecoder;
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
|
||||
for (iDecoder = 0; iDecoder < pOpus->CodecState.iDecodeChannels; iDecoder += 1)
|
||||
{
|
||||
if ((pDecoder = &pOpus->aDecoders[iDecoder]) != NULL)
|
||||
{
|
||||
DirtyMemFree(*pDecoder, VOIP_MEMID, pOpus->iMemGroup, pOpus->pMemGroupUserData);
|
||||
*pDecoder = NULL;
|
||||
}
|
||||
}
|
||||
if (pOpus->pEncoder != NULL)
|
||||
{
|
||||
DirtyMemFree(pOpus->pEncoder, VOIP_MEMID, pOpus->iMemGroup, pOpus->pMemGroupUserData);
|
||||
pOpus->pEncoder = NULL;
|
||||
}
|
||||
|
||||
if (pOpus->pSpeexResampler != NULL)
|
||||
{
|
||||
speex_resampler_destroy(pOpus->pSpeexResampler);
|
||||
pOpus->pSpeexResampler = NULL;
|
||||
}
|
||||
|
||||
DirtyMemFree(pOpus, VOIP_MEMID, pOpus->iMemGroup, pOpus->pMemGroupUserData);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusConvertInt32ToFloat
|
||||
|
||||
\Description
|
||||
Convert int32_t samples into floats, within the same buffer passed in
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input *pInSamples - input int32_t samples
|
||||
\Input iNumSamples - number of samples in pInSamples
|
||||
|
||||
\Output
|
||||
int32_t - number of samples converted
|
||||
|
||||
\Version 04/09/2019 (cvienneau)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusConvertInt32ToFloat(VoipCodecRefT *pState, uint8_t *pInBytes, int32_t iNumSamples)
|
||||
{
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
|
||||
if (pOpus->bInt32Input)
|
||||
{
|
||||
int32_t *pInput = (int32_t*)pInBytes;
|
||||
float *pOutput = (float*)pInBytes;
|
||||
|
||||
int32_t iBufferIndex;
|
||||
for (iBufferIndex = 0; iBufferIndex < iNumSamples; ++iBufferIndex)
|
||||
{
|
||||
pOutput[iBufferIndex] = (float)pInput[iBufferIndex] / INT32_MAX;
|
||||
}
|
||||
return (iBufferIndex);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusResample
|
||||
|
||||
\Description
|
||||
Resample in coming samples to the rate of VOIPOPUS_DEFAULT_SAMPLING_RATE.
|
||||
If VOIPOPUS_DEFAULT_SAMPLING_RATE equal iNumSamples no resampling is done.
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input *pInBytes - input samples in byte array
|
||||
\Input iNumSamples - number of samples in pInBytes
|
||||
\Input *pOutBytes - output samples written
|
||||
\Input uOutBuffSize - size of pOutBytes
|
||||
|
||||
\Output
|
||||
int32_t - number of samples written
|
||||
|
||||
\Version 03/26/2019 (tcho)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusResample(VoipCodecRefT *pState, const uint8_t *pInBytes, int32_t iNumSamples, uint8_t *pOutBytes, uint32_t uOutBuffSize)
|
||||
{
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
int32_t iOutputSamples = iNumSamples; //default skipped resample
|
||||
int32_t iError;
|
||||
|
||||
if (pOpus->bFloatInput)
|
||||
{
|
||||
iOutputSamples = uOutBuffSize / sizeof(float); //goes into speex_resampler_process_float as buffer size, comes out as samples written
|
||||
if ((iError = speex_resampler_process_float(pOpus->pSpeexResampler, 0, (const float *)pInBytes, (uint32_t *)&iNumSamples, (float *)pOutBytes, (uint32_t *)&iOutputSamples)) != 0)
|
||||
{
|
||||
NetPrintf(("voipopus: error resampling float, %d input samples (Error = %d).\n", iNumSamples, iError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iOutputSamples = uOutBuffSize / sizeof(int16_t); //goes into speex_resampler_process_int as buffer size, comes out as samples written
|
||||
if ((iError = speex_resampler_process_int(pOpus->pSpeexResampler, 0, (const int16_t *)pInBytes, (uint32_t *)&iNumSamples, (int16_t *)pOutBytes, (uint32_t *)&iOutputSamples)) != 0)
|
||||
{
|
||||
NetPrintf(("voipopus: error resampling int16, %d input samples, %d (Error = %d).\n", iNumSamples, iError));
|
||||
}
|
||||
}
|
||||
|
||||
return(iOutputSamples);
|
||||
}
|
||||
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusEncodeBlock
|
||||
|
||||
\Description
|
||||
Encode a buffer 16-bit audio or float sample using the Opus encoder
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input *pOutput - [out] outbut buffer
|
||||
\Input *pInput - input buffer
|
||||
\Input iNumSamples - the number of samples to encode
|
||||
|
||||
\Output
|
||||
int32_t - positive=number of encoded bytes, negative=error
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusEncodeBlock(VoipCodecRefT *pState, uint8_t *pOutput, const int16_t *pInput, int32_t iNumSamples)
|
||||
{
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
int32_t iResult = -1;
|
||||
uint32_t uSampleRateIn;
|
||||
uint8_t aResampledData[VOIPOPUS_RESAMPLE_BUFFER_SIZE];
|
||||
|
||||
/* if we haven't set a sample rate manually via the 'insr' control calculate the sample rate based on number of samples. this is with the assumption of 20ms audio
|
||||
$$todo$$ investigate removing the manual calls of 'insr' on xbox if we can confirm that this calculation works */
|
||||
uSampleRateIn = (pOpus->uSampleRateIn == 0) ? VOIPOPUS_GetSampleRate(iNumSamples) : pOpus->uSampleRateIn;
|
||||
|
||||
// convert the data to a useable format if needed
|
||||
iResult = _VoipOpusConvertInt32ToFloat(pState, (uint8_t*)pInput, iNumSamples);
|
||||
|
||||
if (uSampleRateIn != VOIPOPUS_DEFAULT_SAMPLING_RATE)
|
||||
{
|
||||
// re-create the resampler if needed
|
||||
if (uSampleRateIn != pOpus->uResamplerRate)
|
||||
{
|
||||
if (pOpus->pSpeexResampler != NULL)
|
||||
{
|
||||
speex_resampler_destroy(pOpus->pSpeexResampler);
|
||||
}
|
||||
if ((pOpus->pSpeexResampler = speex_resampler_init_frac(VOIPOPUS_DEFAULT_CHANNELS, uSampleRateIn, VOIPOPUS_DEFAULT_SAMPLING_RATE, uSampleRateIn, VOIPOPUS_DEFAULT_SAMPLING_RATE, VOIPOPUS_RESAMPLER_QUALITY, &iResult)) == NULL)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to allocate resampler (Error = %d).\n", iResult));
|
||||
return(iResult);
|
||||
}
|
||||
pOpus->uResamplerRate = uSampleRateIn;
|
||||
}
|
||||
|
||||
// resample the data if needed
|
||||
iResult = _VoipOpusResample(pState, (uint8_t*)pInput, iNumSamples, aResampledData, sizeof(aResampledData));
|
||||
if (iResult != iNumSamples)
|
||||
{
|
||||
pInput = (const int16_t*)aResampledData;
|
||||
iNumSamples = iResult;
|
||||
}
|
||||
}
|
||||
|
||||
// encode as float or int16
|
||||
if (pOpus->bFloatInput)
|
||||
{
|
||||
if ((iResult = opus_encode_float(pOpus->pEncoder, (float*)pInput, iNumSamples, pOutput, VOIPOPUS_MAX_OUTPUT)) < 0)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to encode float (err=%s)\n", DirtyErrGetNameList(iResult, _VoipOpus_aErrList)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((iResult = opus_encode(pOpus->pEncoder, pInput, iNumSamples, pOutput, VOIPOPUS_MAX_OUTPUT)) < 0)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to encode int16_t (err=%s)\n", DirtyErrGetNameList(iResult, _VoipOpus_aErrList)));
|
||||
}
|
||||
}
|
||||
return(iResult);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusDecodeBlock
|
||||
|
||||
\Description
|
||||
Decode a Opus encoded input to 16-bit linear PCM samples
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input *pOutput - [out] outbut buffer
|
||||
\Input *pInput - input buffer
|
||||
\Input iInputBytes - size of the input buffer
|
||||
\Input iChannel - the decode channel for which we are decoding data
|
||||
|
||||
\Output
|
||||
int32_t - positive=number of decoded samples, negative=error
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusDecodeBlock(VoipCodecRefT *pState, int32_t *pOutput, const uint8_t *pInput, int32_t iInputBytes, int32_t iChannel)
|
||||
{
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
int32_t iResult, iSample;
|
||||
int16_t aOutput[VOIPOPUS_MAX_FRAME];
|
||||
|
||||
if ((iChannel < 0) || (iChannel > pOpus->CodecState.iDecodeChannels))
|
||||
{
|
||||
NetPrintf(("voipopus: trying to decode with invalid decoder channel\n"));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ((iResult = opus_decode(pOpus->aDecoders[iChannel], pInput, iInputBytes, aOutput, VOIPOPUS_MAX_FRAME, 0)) < 0)
|
||||
{
|
||||
NetPrintf(("voipopus: unable to decode (err=%s)\n", DirtyErrGetNameList(iResult, _VoipOpus_aErrList)));
|
||||
}
|
||||
|
||||
// accumulate output in the expected format
|
||||
for (iSample = 0; iSample < iResult; iSample += 1)
|
||||
{
|
||||
pOutput[iSample] += (aOutput[iSample] * pOpus->iOutputVolume) >> VOIP_CODEC_OUTPUT_FRACTIONAL;
|
||||
}
|
||||
return(iResult);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusReset
|
||||
|
||||
\Description
|
||||
Reset the codec state
|
||||
|
||||
\Input *pState - codec state
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static void _VoipOpusReset(VoipCodecRefT *pState)
|
||||
{
|
||||
int32_t iChannel;
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
|
||||
opus_encoder_ctl(pOpus->pEncoder, OPUS_RESET_STATE);
|
||||
|
||||
for (iChannel = 0; iChannel < pOpus->CodecState.iDecodeChannels; iChannel += 1)
|
||||
{
|
||||
opus_decoder_ctl(pOpus->aDecoders[iChannel], OPUS_RESET_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusControl
|
||||
|
||||
\Description
|
||||
Set control options
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input iControl - control selector
|
||||
\Input iValue - selector specific
|
||||
\Input iValue2 - selector specific
|
||||
\Input *pValue - selector specific
|
||||
|
||||
\Output
|
||||
int32_t - selector specific
|
||||
|
||||
\Notes
|
||||
iControl can be one of the following:
|
||||
|
||||
\verbatim
|
||||
'plvl' - Set the output volumn
|
||||
'infl' - Set if the input samples are float via iValue, (default int16)
|
||||
'inin' - Set if the input samples are int32_t via iValue, (default int16)
|
||||
'insr' - Set the input sample rate
|
||||
'spam' - Set debug output verbosity
|
||||
\endverbatim
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusControl(VoipCodecRefT *pState, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue)
|
||||
{
|
||||
VoipOpusRefT *pOpus = (VoipOpusRefT *)pState;
|
||||
|
||||
if (iControl == 'plvl')
|
||||
{
|
||||
pOpus->iOutputVolume = iValue;
|
||||
return(0);
|
||||
}
|
||||
if (iControl == 'infl')
|
||||
{
|
||||
pOpus->bInt32Input = FALSE;
|
||||
pOpus->bFloatInput = iValue;
|
||||
return(0);
|
||||
}
|
||||
if (iControl == 'inin')
|
||||
{
|
||||
pOpus->bInt32Input = iValue; //int32s are converted to float, so we set both
|
||||
pOpus->bFloatInput = iValue;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (iControl == 'insr')
|
||||
{
|
||||
pOpus->uSampleRateIn = iValue;
|
||||
return(0);
|
||||
}
|
||||
if (iControl == 'spam')
|
||||
{
|
||||
pOpus->iVerbose = iValue;
|
||||
return(0);
|
||||
}
|
||||
// unhandled control
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipOpusStatus
|
||||
|
||||
\Description
|
||||
Get codec status
|
||||
|
||||
\Input *pState - codec state
|
||||
\Input iSelect - status selector
|
||||
\Input iValue - selector-specific
|
||||
\Input *pBuffer - [out] storage for selector output
|
||||
\Input iBufSize - size of output buffer
|
||||
|
||||
\Output
|
||||
int32_t - selector specific
|
||||
|
||||
\Notes
|
||||
iSelect can be one of the following:
|
||||
|
||||
\verbatim
|
||||
'vlen' - returns TRUE to indicate we are using variable length frames
|
||||
\endverbatim
|
||||
|
||||
\Version 07/03/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************F*/
|
||||
static int32_t _VoipOpusStatus(VoipCodecRefT *pState, int32_t iSelect, int32_t iValue, void *pBuffer, int32_t iBufSize)
|
||||
{
|
||||
if (iSelect == 'vlen')
|
||||
{
|
||||
*(uint8_t *)pBuffer = TRUE;
|
||||
return(0);
|
||||
}
|
||||
// unhandle selector
|
||||
return(-1);
|
||||
}
|
663
src/thirdparty/dirtysdk/contrib/voipaux/source/voipspeex.c
vendored
Normal file
663
src/thirdparty/dirtysdk/contrib/voipaux/source/voipspeex.c
vendored
Normal file
@ -0,0 +1,663 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
\File voipspeex.c
|
||||
|
||||
\Description
|
||||
PC Audio Encoder / Decoder using Speex
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2007. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 04/02/2007 (cadam) First version
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
#include "DirtySDK/dirtysock/dirtymem.h"
|
||||
|
||||
#include "voipspeex.h"
|
||||
|
||||
#include <speex/speex.h>
|
||||
#include <speex/speex_preprocess.h>
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define VOIPSPEEX_ENABLED (TRUE) // enable speex codec
|
||||
|
||||
#ifndef VOIPSPEEX_PREPROCESS
|
||||
#define VOIPSPEEX_PREPROCESS (0) // Speex preprocessor
|
||||
#endif
|
||||
|
||||
// encode/decode information
|
||||
#define VOIPSPEEX_FRAME_SIZE (160)
|
||||
#define VOIPSPEEX_MAX_BYTES (200)
|
||||
#define VOIPSPEEX_COMP_SIZE (38)
|
||||
|
||||
// speex settings
|
||||
#define VOIPSPEEX_COMPLEXITY (1)
|
||||
#define VOIPSPEEX_QUALITY (8)
|
||||
#define VOIPSPEEX_PERCEPTUAL (1)
|
||||
|
||||
// speex preprocessor settings
|
||||
#define VOIPSPEEX_DENOISE (1)
|
||||
#define VOIPSPEEX_AGC (1)
|
||||
#define VOIPSPEEX_PROB_START (30)
|
||||
#define VOIPSPEEX_PROB_CONTINUE (7)
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! voipspeex decoder ref
|
||||
typedef struct VoipSpeexDecoderT
|
||||
{
|
||||
int32_t iChannel;
|
||||
void *pDecodeState;
|
||||
} VoipSpeexDecoderT;
|
||||
|
||||
//! voipspeex module state
|
||||
typedef struct VoipSpeexStateT
|
||||
{
|
||||
VoipCodecRefT CodecState;
|
||||
|
||||
// module memory group
|
||||
int32_t iMemGroup;
|
||||
void *pMemGroupUserData;
|
||||
|
||||
int32_t iNumChannels;
|
||||
|
||||
int32_t iOutputVolume;
|
||||
|
||||
SpeexBits sEncodeBits;
|
||||
SpeexBits *pDecodeBits;
|
||||
|
||||
void *pEncodeState;
|
||||
VoipSpeexDecoderT *pDecoders;
|
||||
SpeexPreprocessState *pPreprocessor;
|
||||
|
||||
#if DIRTYCODE_LOGGING
|
||||
int32_t iDebugLevel;
|
||||
#endif
|
||||
} VoipSpeexStateT;
|
||||
|
||||
|
||||
/*** Function Prototypes ***************************************************************/
|
||||
|
||||
#if VOIPSPEEX_ENABLED
|
||||
static VoipCodecRefT *_VoipSpeexCreate(int32_t iDecodeChannels);
|
||||
static void _VoipSpeexDestroy(VoipCodecRefT *pState);
|
||||
static int32_t _VoipSpeexEncodeBlock(VoipCodecRefT *pState, uint8_t *pOut, const int16_t *pInp, int32_t iNumSamples);
|
||||
static int32_t _VoipSpeexDecodeBlock(VoipCodecRefT *pState, int32_t *pOut, const uint8_t *pInp, int32_t iInputBytes, int32_t iChannel);
|
||||
static void _VoipSpeexReset(VoipCodecRefT *pState);
|
||||
static int32_t _VoipSpeexControl(VoipCodecRefT *pState, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
static int32_t _VoipSpeexStatus(VoipCodecRefT *pState, int32_t iSelect, int32_t iValue, void *pBuffer, int32_t iBufSize);
|
||||
#else
|
||||
static VoipCodecRefT *_VoipSpeexCreate(int32_t iDecodeChannels) { return NULL; }
|
||||
static void _VoipSpeexDestroy(VoipCodecRefT *pState) { }
|
||||
static int32_t _VoipSpeexEncodeBlock(VoipCodecRefT *pState, uint8_t *pOut, const int16_t *pInp, int32_t iNumSamples) { return -1; }
|
||||
static int32_t _VoipSpeexDecodeBlock(VoipCodecRefT *pState, int32_t *pOut, const uint8_t *pInp, int32_t iInputBytes, int32_t iChannel) { return -1; }
|
||||
static void _VoipSpeexReset(VoipCodecRefT *pState) { }
|
||||
static int32_t _VoipSpeexControl(VoipCodecRefT *pState, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue) { return -1; }
|
||||
static int32_t _VoipSpeexStatus(VoipCodecRefT *pState, int32_t iSelect, int32_t iValue, void *pBuffer, int32_t iBufSize) { return -1; }
|
||||
#endif
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
//! voipspeex codec block
|
||||
const VoipCodecDefT VoipSpeex_CodecDef =
|
||||
{
|
||||
_VoipSpeexCreate,
|
||||
_VoipSpeexDestroy,
|
||||
_VoipSpeexEncodeBlock,
|
||||
_VoipSpeexDecodeBlock,
|
||||
_VoipSpeexReset,
|
||||
_VoipSpeexControl,
|
||||
_VoipSpeexStatus,
|
||||
};
|
||||
|
||||
#if VOIPSPEEX_ENABLED
|
||||
|
||||
/*** Private Functions *****************************************************************/
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexSetControls
|
||||
|
||||
\Description
|
||||
Sets all the controls on the codec
|
||||
|
||||
\Input pCodecState - codec state
|
||||
|
||||
\Version 01/12/08 (grouse)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static void _VoipSpeexSetControls( VoipCodecRefT *pCodecState )
|
||||
{
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
|
||||
int32_t iChannel;
|
||||
|
||||
int32_t iComplexity = VOIPSPEEX_COMPLEXITY;
|
||||
int32_t iQuality = VOIPSPEEX_QUALITY;
|
||||
int32_t iPerceptual = VOIPSPEEX_PERCEPTUAL;
|
||||
|
||||
#if VOIPSPEEX_PREPROCESS
|
||||
int32_t iDenoise = VOIPSPEEX_DENOISE;
|
||||
int32_t iAGC = VOIPSPEEX_AGC;
|
||||
int32_t iProbStart = VOIPSPEEX_PROB_START;
|
||||
int32_t iProbContinue = VOIPSPEEX_PROB_CONTINUE;
|
||||
#endif
|
||||
|
||||
int32_t iReturnVal = 0;
|
||||
|
||||
iReturnVal = speex_encoder_ctl(pState->pEncodeState, SPEEX_SET_COMPLEXITY, &iComplexity);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error setting encoder control SPEEX_SET_COMPLEXITY with code %d\n", iReturnVal));
|
||||
}
|
||||
|
||||
iReturnVal = speex_encoder_ctl(pState->pEncodeState, SPEEX_SET_QUALITY, &iQuality);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error setting encoder control SPEEX_SET_QUALITY with code %d\n", iReturnVal));
|
||||
}
|
||||
|
||||
for (iChannel=0; iChannel < pState->CodecState.iDecodeChannels; iChannel++)
|
||||
{
|
||||
iReturnVal = speex_decoder_ctl(pState->pDecoders[iChannel].pDecodeState, SPEEX_SET_ENH, &iPerceptual);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error setting decoder control SPEEX_SET_ENH for decoder %d with code %d\n", iChannel, iReturnVal));
|
||||
}
|
||||
}
|
||||
|
||||
#if VOIPSPEEX_PREPROCESS
|
||||
iReturnVal = speex_preprocess_ctl(pState->pPreprocessor, SPEEX_PREPROCESS_SET_DENOISE, &iDenoise);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error setting preprocessor control SPEEX_PREPROCESS_SET_DENOISE with code %d\n", iReturnVal));
|
||||
}
|
||||
|
||||
iReturnVal = speex_preprocess_ctl(pState->pPreprocessor, SPEEX_PREPROCESS_SET_AGC, &iAGC);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error setting preprocessor control SPEEX_PREPROCESS_SET_AGC with code %d\n", iReturnVal));
|
||||
}
|
||||
|
||||
iReturnVal = speex_preprocess_ctl(pState->pPreprocessor, SPEEX_PREPROCESS_SET_PROB_START, &iProbStart);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error re-setting preprocessor control SPEEX_PREPROCESS_SET_PROB_START with code %d\n", iReturnVal));
|
||||
}
|
||||
|
||||
iReturnVal = speex_preprocess_ctl(pState->pPreprocessor, SPEEX_PREPROCESS_SET_PROB_CONTINUE, &iProbContinue);
|
||||
if( iReturnVal != 0 )
|
||||
{
|
||||
NetPrintf(("voipspeex: error re-setting preprocessor control SPEEX_PREPROCESS_SET_PROB_CONTINUE with code %d\n", iReturnVal));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexCreate
|
||||
|
||||
\Description
|
||||
Create a Speex codec state.
|
||||
|
||||
\Input iDecodeChannels - number of decoder channels
|
||||
|
||||
\Output
|
||||
VoipCodecStateT * - pointer to speex codec state
|
||||
|
||||
\Version 04/02/2007 (cadam)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static VoipCodecRefT *_VoipSpeexCreate(int32_t iDecodeChannels)
|
||||
{
|
||||
VoipSpeexStateT *pState;
|
||||
int32_t iMemGroup;
|
||||
void *pMemGroupUserData;
|
||||
int32_t iChannel;
|
||||
|
||||
// Query mem group id
|
||||
iMemGroup = VoipStatus(NULL, 'mgrp', 0, NULL, 0);
|
||||
|
||||
// Query mem group user data
|
||||
VoipStatus(NULL, 'mgud', 0, &pMemGroupUserData, sizeof(pMemGroupUserData));
|
||||
|
||||
// allocate memory for the state structure and initialize the variables
|
||||
pState = (VoipSpeexStateT *)DirtyMemAlloc(sizeof(VoipSpeexStateT), VOIP_MEMID, iMemGroup, pMemGroupUserData);
|
||||
ds_memclr(pState, sizeof(VoipSpeexStateT));
|
||||
NetPrintfVerbose((pState->iDebugLevel, 0, "voipspeex: allocated module reference at %p\n", pState));
|
||||
|
||||
// initialize the state variables
|
||||
pState->CodecState.pCodecDef = &VoipSpeex_CodecDef;
|
||||
pState->CodecState.iDecodeChannels = iDecodeChannels;
|
||||
pState->CodecState.bVadEnabled = TRUE;
|
||||
pState->iMemGroup = iMemGroup;
|
||||
pState->pMemGroupUserData = pMemGroupUserData;
|
||||
pState->iNumChannels = iDecodeChannels;
|
||||
|
||||
// set the power threshold and output level
|
||||
pState->iOutputVolume = 1 << VOIP_CODEC_OUTPUT_FRACTIONAL;
|
||||
|
||||
// initialize the speex bits
|
||||
speex_bits_init(&pState->sEncodeBits);
|
||||
|
||||
// create and initialize the encoder
|
||||
pState->pEncodeState = speex_encoder_init(&speex_nb_mode);
|
||||
if (pState->pEncodeState == NULL)
|
||||
{
|
||||
NetPrintf(("voipspeex: failed to create encoder\n"));
|
||||
speex_bits_destroy(&pState->sEncodeBits);
|
||||
DirtyMemFree(pState, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// allocate an array of pointers to hold pointers to one decoder per channel
|
||||
pState->pDecoders = DirtyMemAlloc(sizeof(VoipSpeexDecoderT) * iDecodeChannels, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
NetPrintfVerbose((pState->iDebugLevel, 0, "voipspeex: decoder array allocated %d bytes at %p\n", sizeof(VoipSpeexDecoderT) * iDecodeChannels, pState->pDecoders));
|
||||
pState->pDecodeBits = DirtyMemAlloc(sizeof(SpeexBits) * iDecodeChannels, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
NetPrintfVerbose((pState->iDebugLevel, 0, "voipspeex: decode bits array allocated %d bytes at %p\n", sizeof(SpeexBits) * iDecodeChannels, pState->pDecodeBits));
|
||||
|
||||
// initialize the decoders
|
||||
for (iChannel = 0; iChannel < pState->iNumChannels; iChannel++)
|
||||
{
|
||||
pState->pDecoders[iChannel].iChannel = iChannel;
|
||||
pState->pDecoders[iChannel].pDecodeState = speex_decoder_init(&speex_nb_mode);
|
||||
|
||||
if (pState->pDecoders[iChannel].pDecodeState == NULL)
|
||||
{
|
||||
// we only need to destroy the ones before the failure
|
||||
pState->iNumChannels = iChannel;
|
||||
|
||||
NetPrintf(("voipspeex: failed to create decoder %d\n", iChannel));
|
||||
for (iChannel = 0; iChannel < pState->iNumChannels; iChannel++)
|
||||
{
|
||||
speex_decoder_destroy(pState->pDecoders[iChannel].pDecodeState);
|
||||
speex_bits_destroy(&pState->pDecodeBits[iChannel]);
|
||||
}
|
||||
|
||||
DirtyMemFree(pState->pDecoders, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
DirtyMemFree(pState->pDecodeBits, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
speex_encoder_destroy(pState->pEncodeState);
|
||||
DirtyMemFree(pState, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
speex_bits_init(&pState->pDecodeBits[iChannel]);
|
||||
}
|
||||
|
||||
#if VOIPSPEEX_PREPROCESS
|
||||
pState->pPreprocessor = speex_preprocess_state_init(VOIPSPEEX_FRAME_SIZE, 8000);
|
||||
if (pState->pPreprocessor == NULL)
|
||||
{
|
||||
NetPrintf(("voipspeex: Failed to create pre-processor\n"));
|
||||
|
||||
for (iChannel = 0; iChannel < pState->iNumChannels; iChannel++)
|
||||
{
|
||||
if (pState->pDecoders[iChannel].pDecodeState)
|
||||
{
|
||||
speex_decoder_destroy(pState->pDecoders[iChannel].pDecodeState);
|
||||
speex_bits_destroy(&pState->pDecodeBits[iChannel]);
|
||||
}
|
||||
}
|
||||
|
||||
DirtyMemFree(pState->pDecoders, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
DirtyMemFree(pState->pDecodeBits, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
speex_encoder_destroy(pState->pEncodeState);
|
||||
DirtyMemFree(pState, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
#else
|
||||
pState->pPreprocessor = NULL;
|
||||
#endif
|
||||
|
||||
_VoipSpeexSetControls(&pState->CodecState);
|
||||
|
||||
NetPrintfVerbose((pState->iDebugLevel, 0, "voipspeex: returning %p\n", &pState->CodecState));
|
||||
return(&pState->CodecState);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexDestroy
|
||||
|
||||
\Description
|
||||
Destroy a Speex codec state.
|
||||
|
||||
\Input *pState - state to destroy
|
||||
|
||||
\Version 04/02/2007 (cadam)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static void _VoipSpeexDestroy(VoipCodecRefT *pCodecState)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
|
||||
#if VOIPSPEEX_PREPROCESS
|
||||
speex_preprocess_state_destroy(pState->pPreprocessor);
|
||||
#endif
|
||||
|
||||
// destroy the decoders then free the memory that was allocated for them
|
||||
for (i = 0; i < pState->iNumChannels; i++)
|
||||
{
|
||||
speex_decoder_destroy(pState->pDecoders[i].pDecodeState);
|
||||
speex_bits_destroy(&pState->pDecodeBits[i]);
|
||||
}
|
||||
|
||||
// free the array that held the decoders
|
||||
DirtyMemFree(pState->pDecoders, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
|
||||
// free the array that held the decode bits
|
||||
DirtyMemFree(pState->pDecodeBits, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
|
||||
// destroy the encoder
|
||||
speex_encoder_destroy(pState->pEncodeState);
|
||||
|
||||
// destroy the SpeexBits
|
||||
speex_bits_destroy(&pState->sEncodeBits);
|
||||
|
||||
// free the state
|
||||
DirtyMemFree(pState, VOIP_MEMID, pState->iMemGroup, pState->pMemGroupUserData);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexEncodeBlock
|
||||
|
||||
\Description
|
||||
Encode a buffer 16-bit audio samples using the Speex encoder.
|
||||
|
||||
\Input *pState - pointer to encode state
|
||||
\Input *pOut - pointer to output buffer
|
||||
\Input *pInp - pointer to input buffer
|
||||
\Input iNumSamples - number of samples to encode
|
||||
|
||||
\Output
|
||||
int32_t - size of compressed data in bytes
|
||||
|
||||
\Version 04/05/2007 (cadam)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static int32_t _VoipSpeexEncodeBlock(VoipCodecRefT *pCodecState, unsigned char *pOut, const int16_t *pInp, int32_t iNumSamples)
|
||||
{
|
||||
int32_t iFrame, iNumFrames, iSample;
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
unsigned char *pOutput = pOut;
|
||||
const int16_t *pInput = pInp;
|
||||
spx_int16_t iFrameBuffer[VOIPSPEEX_FRAME_SIZE];
|
||||
int32_t iNumBytes, iNumBytesEncoded = 0;
|
||||
|
||||
iNumFrames = iNumSamples/VOIPSPEEX_FRAME_SIZE;
|
||||
|
||||
NetPrintfVerbose((pState->iDebugLevel, 2, "voipspeex: encoding %d samples (%d frames)\n", iNumSamples, iNumFrames));
|
||||
|
||||
if ((iNumSamples % VOIPSPEEX_FRAME_SIZE) != 0)
|
||||
{
|
||||
NetPrintf(("voipspeex: error - speex encoder can only encode multiples of %d samples.\n", VOIPSPEEX_FRAME_SIZE));
|
||||
return(0);
|
||||
}
|
||||
|
||||
for (iFrame = 0; iFrame < iNumFrames; iFrame++)
|
||||
{
|
||||
ds_memclr(iFrameBuffer, sizeof(iFrameBuffer));
|
||||
|
||||
// convert the 16 bit input values to a float buffer for Speex
|
||||
for (iSample = 0; iSample < VOIPSPEEX_FRAME_SIZE; iSample++)
|
||||
{
|
||||
iFrameBuffer[iSample] = pInput[iSample];
|
||||
}
|
||||
|
||||
// reset the SpeexBits
|
||||
speex_bits_reset(&pState->sEncodeBits);
|
||||
|
||||
#if VOIPSPEEX_PREPROCESS
|
||||
speex_preprocess(pState->pPreprocessor, iFrameBuffer, NULL);
|
||||
#endif
|
||||
|
||||
// encode the frame
|
||||
speex_encode_int(pState->pEncodeState, iFrameBuffer, &pState->sEncodeBits);
|
||||
|
||||
// write the result to the output and get the number of bytes written
|
||||
iNumBytes = speex_bits_write(&pState->sEncodeBits, (char *)pOutput, VOIPSPEEX_MAX_BYTES);
|
||||
|
||||
// increment the pointers and the total number of bytes written
|
||||
pInput += VOIPSPEEX_FRAME_SIZE;
|
||||
pOutput += iNumBytes;
|
||||
iNumBytesEncoded += iNumBytes;
|
||||
}
|
||||
|
||||
return(iNumBytesEncoded);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexDecodeBlock
|
||||
|
||||
\Description
|
||||
Decode Speex-encoded input to 16-bit linear PCM samples, and accumulate in the given output buffer.
|
||||
|
||||
\Input *pState - pointer to decode state
|
||||
\Input *pOut - pointer to output buffer
|
||||
\Input *pInp - pointer to input buffer
|
||||
\Input iInputBytes - size of input data
|
||||
\Input iChannel - the decode channel for which we are decoding data
|
||||
|
||||
\Output
|
||||
int32_t - number of samples decoded
|
||||
|
||||
\Version 04/05/2007 (cadam)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static int32_t _VoipSpeexDecodeBlock(VoipCodecRefT *pCodecState, int32_t *pOut, const unsigned char *pInp, int32_t iInputBytes, int32_t iChannel)
|
||||
{
|
||||
int32_t iFrame, iFrameSize, iNumFrames, iSample;
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
int32_t *pOutput = pOut;
|
||||
unsigned char *pInput = (unsigned char *)pInp;
|
||||
spx_int16_t iFrameBuffer[VOIPSPEEX_FRAME_SIZE];
|
||||
|
||||
iFrameSize = VOIPSPEEX_COMP_SIZE;
|
||||
iNumFrames = iInputBytes/iFrameSize;
|
||||
if (iInputBytes == 0)
|
||||
{
|
||||
NetPrintf(("voipspeex: no data to decode\n"));
|
||||
return(0);
|
||||
}
|
||||
if ((iInputBytes % iFrameSize) != 0)
|
||||
{
|
||||
NetPrintf(("voipspeex: speex decoder can only decode multiples of %d bytes (%d submitted)\n", iFrameSize, iInputBytes));
|
||||
return(0);
|
||||
}
|
||||
|
||||
NetPrintfVerbose((pState->iDebugLevel, 2, "voipspeex: decoding %d bytes (%d frames)\n", iInputBytes, iNumFrames));
|
||||
|
||||
for (iFrame = 0; iFrame < iNumFrames; iFrame++)
|
||||
{
|
||||
ds_memclr(iFrameBuffer, sizeof(iFrameBuffer));
|
||||
|
||||
// reset the SpeexBits
|
||||
speex_bits_reset(&pState->pDecodeBits[iChannel]);
|
||||
|
||||
// read the bits from the input
|
||||
speex_bits_read_from(&pState->pDecodeBits[iChannel], (char *)pInput, iFrameSize);
|
||||
|
||||
// decode the bits
|
||||
speex_decode_int(pState->pDecoders[iChannel].pDecodeState, &pState->pDecodeBits[iChannel], iFrameBuffer);
|
||||
|
||||
// convert the float buffer to an int32_t array for Speex
|
||||
for (iSample = 0; iSample < VOIPSPEEX_FRAME_SIZE; iSample++)
|
||||
{
|
||||
pOutput[iSample] += (((int32_t)iFrameBuffer[iSample] * pState->iOutputVolume) >> VOIP_CODEC_OUTPUT_FRACTIONAL);
|
||||
}
|
||||
|
||||
// increment the pointers and the total number of bytes written
|
||||
pInput += iFrameSize;
|
||||
pOutput += VOIPSPEEX_FRAME_SIZE;
|
||||
}
|
||||
|
||||
return(iNumFrames * VOIPSPEEX_FRAME_SIZE);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexReset
|
||||
|
||||
\Description
|
||||
Resets codec state.
|
||||
|
||||
\Input *pState - pointer to decode state
|
||||
|
||||
\Version 04/05/2007 (cadam)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static void _VoipSpeexReset(VoipCodecRefT *pCodecState)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
|
||||
// reset the SpeexBits
|
||||
speex_bits_reset(&pState->sEncodeBits);
|
||||
|
||||
// reset the encoder
|
||||
speex_encoder_ctl(pState->pEncodeState, SPEEX_RESET_STATE, NULL);
|
||||
|
||||
// reset the decoders
|
||||
for (i = 0; i < pState->iNumChannels; i++)
|
||||
{
|
||||
speex_decoder_ctl(pState->pDecoders[i].pDecodeState, SPEEX_RESET_STATE, NULL);
|
||||
}
|
||||
|
||||
_VoipSpeexSetControls(&pState->CodecState);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexControl
|
||||
|
||||
\Description
|
||||
Modifies parameters of the codec
|
||||
|
||||
\Input *pState - pointer to decode state
|
||||
\Input iControl - control selector
|
||||
\Input iValue - selector specific
|
||||
\Input iValue2 - selector specific
|
||||
\Input *pValue - selector specific
|
||||
|
||||
\Output
|
||||
int32_t - selector specific
|
||||
|
||||
\Notes
|
||||
iControl can be one of the following:
|
||||
|
||||
\verbatim
|
||||
'plvl' - Set the output power level
|
||||
'spam' - Set debug output verbosity (debug only)
|
||||
\endverbatim
|
||||
|
||||
\Version 03/12/2008 (grouse)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static int32_t _VoipSpeexControl(VoipCodecRefT *pCodecState, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue)
|
||||
{
|
||||
VoipSpeexStateT *pState = (VoipSpeexStateT *)pCodecState;
|
||||
|
||||
if ((iControl == 'plvl') && (pState != NULL))
|
||||
{
|
||||
pState->iOutputVolume = iValue;
|
||||
return(0);
|
||||
}
|
||||
#if DIRTYCODE_LOGGING
|
||||
if ((iControl == 'spam') && (pState != NULL))
|
||||
{
|
||||
pState->iDebugLevel = iValue;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
NetPrintf(("voipspeex: unhandled control selector '%C'\n", iControl));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*F*************************************************************************************************/
|
||||
/*!
|
||||
\Function _VoipSpeexStatus
|
||||
|
||||
\Description
|
||||
Get codec status
|
||||
|
||||
\Input *pCodecState - pointer to decode state
|
||||
\Input iSelect - status selector
|
||||
\Input iValue - selector-specific
|
||||
\Input *pBuffer - [out] storage for selector output
|
||||
\Input iBufSize - size of output buffer
|
||||
|
||||
\Output
|
||||
int32_t - selector specific
|
||||
|
||||
\Notes
|
||||
iSelect can be one of the following:
|
||||
|
||||
\verbatim
|
||||
'fsiz' - size of encoder output / decoder input in bytes (iValue=samples per frame)
|
||||
'fsmp' - frame sample size for current codec
|
||||
\endverbatim
|
||||
|
||||
\Version 10/11/2011 (jbrookes)
|
||||
*/
|
||||
/*************************************************************************************************F*/
|
||||
static int32_t _VoipSpeexStatus(VoipCodecRefT *pCodecState, int32_t iSelect, int32_t iValue, void *pBuffer, int32_t iBufSize)
|
||||
{
|
||||
VoipSpeexStateT *pModuleState = (VoipSpeexStateT *)pCodecState;
|
||||
|
||||
// these options require module state
|
||||
if (pModuleState != NULL)
|
||||
{
|
||||
if (iSelect == 'fsiz')
|
||||
{
|
||||
return((iValue/VOIPSPEEX_FRAME_SIZE) * VOIPSPEEX_COMP_SIZE);
|
||||
}
|
||||
if (iSelect == 'fsmp')
|
||||
{
|
||||
return(VOIPSPEEX_FRAME_SIZE);
|
||||
}
|
||||
}
|
||||
NetPrintfVerbose((pModuleState->iDebugLevel, 1, "voipspeex: unhandled status selector '%C'\n", iSelect));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// speex function overrides
|
||||
void _speex_fatal(const char *str, const char *file, int line)
|
||||
{
|
||||
NetPrintf(("Fatal (internal) error in %s, line %d: %s\n", file, line, str ));
|
||||
}
|
||||
|
||||
void speex_warning(const char *str)
|
||||
{
|
||||
NetPrintf(("libspeex: warning: %s\n", str));
|
||||
}
|
||||
|
||||
void speex_warning_int(const char *str, int val)
|
||||
{
|
||||
NetPrintf(("libspeex: warning: %s %d\n", str, val));
|
||||
}
|
||||
|
||||
void speex_notify(const char *str)
|
||||
{
|
||||
NetPrintf(("libspeex: notification: %s\n", str));
|
||||
}
|
||||
|
||||
#endif // VOIPSPEEX_ENABLED
|
||||
|
337
src/thirdparty/dirtysdk/include/DirtySDK/comm/commall.h
vendored
Normal file
337
src/thirdparty/dirtysdk/include/DirtySDK/comm/commall.h
vendored
Normal file
@ -0,0 +1,337 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File commall.h
|
||||
|
||||
\Description
|
||||
This is the common communication header required for use with any
|
||||
of the CommXXXX routines. It provides a unified calling structure
|
||||
as well as unified status and error values.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2002
|
||||
|
||||
\Version 0.5 02/23/1999 (gschaefer) First Version
|
||||
\Version 1.0 02/25/1999 (gschaefer) Alpha release
|
||||
\Version 1.1 11/20/2002 (jbrookes) Added Send() flags parameter, protocol definitions.
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _commall_h
|
||||
#define _commall_h
|
||||
|
||||
/*!
|
||||
\Moduledef CommAll CommAll
|
||||
\Modulemember Comm
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define COMM_OFFLINE 1 //!< status - offline
|
||||
#define COMM_CONNECTING 2 //!< status - connecting
|
||||
#define COMM_ONLINE 3 //!< status - online
|
||||
#define COMM_FAILURE 4 //!< status - failure
|
||||
|
||||
#define COMM_PENDING 1 //!< pending
|
||||
#define COMM_NOERROR 0 //!< no error
|
||||
#define COMM_BADPARM -1 //!< invalid parameter
|
||||
#define COMM_BADSTATE -2 //!< invalid state
|
||||
#define COMM_BADADDRESS -3 //!< invalid address
|
||||
#define COMM_NORESOURCE -4 //!< no resources available
|
||||
#define COMM_UNEXPECTED -5 //!< unexpected
|
||||
#define COMM_MINBUFFER -6 //!< minbuffer
|
||||
#define COMM_NODATA -7 //!< no data available
|
||||
#define COMM_INPROGRESS -8 //!< operation in progress
|
||||
#define COMM_PORTBOUND -9 //!< requested local port is already bound
|
||||
|
||||
// start of protocol numbering
|
||||
#define COMM_PROTO_TCP (1) //!< TCP protocol
|
||||
#define COMM_PROTO_UDP (2) //!< UDP protocol
|
||||
#define COMM_PROTO_SRP (3) //!< SRP protocol
|
||||
|
||||
#define COMM_FLAGS_RELIABLE 0 //!< CommRef->Send() flag - use reliable transmission
|
||||
#define COMM_FLAGS_UNRELIABLE 1 //!< CommRef->Send() flag - use unreliable transmission
|
||||
#define COMM_FLAGS_BROADCAST 2 //!< CommRef->Send() flag - use unreliable broadcast transmission
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct CommRef CommRef;
|
||||
|
||||
//! common reference type
|
||||
struct CommRef
|
||||
{
|
||||
//! construct the class
|
||||
/*!
|
||||
* note: initialized winsock for first class. also creates linked
|
||||
* list of all current instances of the class and worker thread
|
||||
* to do most udp stuff.
|
||||
*
|
||||
* entry: maxwid=max record width, maxinp/maxout=input/output packet buffer size
|
||||
* exit: none
|
||||
*/
|
||||
CommRef* (*Construct)(int32_t maxwid, int32_t maxinp, int32_t maxout);
|
||||
|
||||
//! destruct the class
|
||||
/*!
|
||||
* entry: none
|
||||
* exit: none
|
||||
*/
|
||||
void (*Destroy)(CommRef *what);
|
||||
|
||||
//! resolve an address
|
||||
/*!
|
||||
* entry: what=endpoint ref, addr=address, buffer=target buffer, buflen=length
|
||||
* exit: <0=error, 0=in progress, >0=complete
|
||||
*/
|
||||
int32_t (*Resolve)(struct CommRef *what, const char *addr, char *buf, int32_t len, char iDiv);
|
||||
|
||||
//! stop the resolver
|
||||
/*!
|
||||
* entry: what=endpoint ref
|
||||
* exit: none
|
||||
*/
|
||||
void (*Unresolve)(CommRef *what);
|
||||
|
||||
//! listen for a connection
|
||||
/*!
|
||||
* entry: addr=port to listen on (only :port portion used)
|
||||
* exit: negative=error, zero=ok
|
||||
*/
|
||||
int32_t (*Listen)(CommRef *what, const char *addr);
|
||||
|
||||
//! stop listening
|
||||
/*!
|
||||
* entry: none
|
||||
* exit: negative=error, zero=ok
|
||||
*/
|
||||
int32_t (*Unlisten)(CommRef *what);
|
||||
|
||||
//! initiate a connection to a peer
|
||||
/*!
|
||||
* note: does not currently perform dns translation
|
||||
*
|
||||
* entry: addr=address in ip-address:port form
|
||||
* exit: negative=error, zero=ok
|
||||
*/
|
||||
int32_t (*Connect)(CommRef *what, const char *addr);
|
||||
|
||||
//! terminate a connection
|
||||
/*!
|
||||
* entry: none
|
||||
* exit: negative=error, zero=ok
|
||||
*/
|
||||
int32_t (*Unconnect)(CommRef *what);
|
||||
|
||||
//! set event callback hook
|
||||
/*!
|
||||
* Note1: this is an optional callback which is called after new data has been
|
||||
* received and buffered or at other times where the protocol state has
|
||||
* significantly changed. It is called by a private thread so the routines it
|
||||
* uses must be thread safe. It can be used to provide "life" to servers or
|
||||
* other modules which use comm services. The code must not take too long to
|
||||
* execute since it will impact comm performance if it does.
|
||||
*
|
||||
* Note2: By disabling and enabling this callback at specific times, it is
|
||||
* possible to avoid threading concerns in the upper layer (i.e., if you
|
||||
* disable the callback while the callback is executing, this call will block
|
||||
* until the callback completes).
|
||||
*
|
||||
* entry: comm reference
|
||||
* exit: none
|
||||
*/
|
||||
void (*Callback)(CommRef *what, void (*callback)(CommRef *ref, int32_t event));
|
||||
|
||||
//! return current stream status
|
||||
/*!
|
||||
* entry: none
|
||||
* exit: CONNECTING, OFFLINE, ONLINE or FAILURE
|
||||
*/
|
||||
int32_t (*Status)(CommRef *what);
|
||||
|
||||
//! control connection behavior (optional)
|
||||
/*!
|
||||
* see specific implementation for entry and exit parameter descriptions
|
||||
*/
|
||||
int32_t (*Control)(CommRef *what, int32_t iControl, int32_t iValue, void *pValue);
|
||||
|
||||
//! return current clock tick
|
||||
/*!
|
||||
* entry: none
|
||||
* exit: elapsed millisecs from some epoch
|
||||
*/
|
||||
uint32_t (*Tick)(CommRef *what);
|
||||
|
||||
//! send a packet
|
||||
/*!
|
||||
* note: zero length packets may not be sent (they are ignored)
|
||||
*
|
||||
* entry: buffer=pointer to data, length=length of data, flags=COMM_FLAGS_* (see defines above)
|
||||
* exit: negative=error, zero=ok
|
||||
*/
|
||||
int32_t (*Send)(CommRef *what, const void *buffer, int32_t length, uint32_t flags);
|
||||
|
||||
//! peek at waiting packet
|
||||
/*!
|
||||
* entry: target=target buffer, length=buffer length, when=tick received at
|
||||
* exit: negative=nothing pending, else packet length
|
||||
*/
|
||||
int32_t (*Peek)(CommRef *what, void *target, int32_t length, uint32_t *when);
|
||||
|
||||
//! receive a packet from the buffer
|
||||
/*!
|
||||
* entry: target=target buffer, length=buffer length, what=tick received at
|
||||
* exit: negative=error, else packet length
|
||||
*/
|
||||
int32_t (*Recv)(CommRef *what, void *target, int32_t length, uint32_t *when);
|
||||
|
||||
//! send data callback hook
|
||||
/*!
|
||||
* Note: this is an optional callback which is called immediately before
|
||||
* a packet is transmitted. Due to error handling, it may get called more
|
||||
* than once for the same packet if the packet is sent more than once.
|
||||
*
|
||||
* entry: same as Send
|
||||
* exit: none
|
||||
*/
|
||||
void (*SendCallback)(CommRef *what, void *buffer, int32_t length, uint32_t when);
|
||||
|
||||
//! receive data callback hook
|
||||
/*!
|
||||
* Note: this is an optional callback which is called immediately after
|
||||
* a packet is received. By the time this function is called, the packet
|
||||
* is available for input via the Recv function.
|
||||
*
|
||||
* entry: same as Recv
|
||||
* exit: none
|
||||
*/
|
||||
void (*RecvCallback)(CommRef *what, void *target, int32_t length, uint32_t when);
|
||||
|
||||
//! module memory group
|
||||
int32_t memgroup;
|
||||
void *memgrpusrdata;
|
||||
|
||||
//! user definable storage
|
||||
int32_t refnum;
|
||||
|
||||
//! user definable reference
|
||||
void *refptr;
|
||||
|
||||
//! socket ref
|
||||
SocketT *sockptr;
|
||||
|
||||
//! maximum packet width (read only)
|
||||
uint16_t maxwid;
|
||||
|
||||
//! maximum number of input packets buffered
|
||||
uint8_t maxinp;
|
||||
|
||||
//! maximum number of output packets buffered
|
||||
uint8_t maxout;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t datasent;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t datarcvd;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t packsent;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t packrcvd;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t packlost;
|
||||
|
||||
//! data tranfer statictics (read only)
|
||||
uint32_t packsaved; // tracks the number of packers recovered by commudp redundancy mechanism
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t naksent;
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t overhead; // tracks the sent overhead including IP4 and UDP header
|
||||
|
||||
//! data transfer statistics (read only)
|
||||
int32_t rcvoverhead; // tracks the receive overhead including IP4 and UDP header
|
||||
|
||||
//!< host ip address (read only)
|
||||
uint32_t hostip;
|
||||
|
||||
//!< peer ip address (read only)
|
||||
uint32_t peerip;
|
||||
|
||||
//!< host port (read only)
|
||||
uint16_t hostport;
|
||||
|
||||
//!< peer port (read only)
|
||||
uint16_t peerport;
|
||||
|
||||
//!< if packet was received (read only)
|
||||
uint8_t bpackrcvd;
|
||||
|
||||
uint8_t _pad[3];
|
||||
};
|
||||
|
||||
// typedef versions for discrete declarations
|
||||
typedef CommRef *(CommAllConstructT)(int32_t maxwid, int32_t maxinp, int32_t maxout);
|
||||
typedef void (CommAllDestroyT)(CommRef *what);
|
||||
typedef int32_t (CommAllResolveT)(struct CommRef *what, const char *addr, char *buf, int32_t len, char iDiv);
|
||||
typedef void (CommAllUnresolveT)(CommRef *what);
|
||||
typedef int32_t (CommAllListenT)(CommRef *what, const char *addr);
|
||||
typedef int32_t (CommAllUnlistenT)(CommRef *what);
|
||||
typedef int32_t (CommAllConnectT)(CommRef *what, const char *addr);
|
||||
typedef int32_t (CommAllUnconnectT)(CommRef *what);
|
||||
typedef void (CommAllCallbackT)(CommRef *what, void (*callback)(CommRef *ref, int32_t event));
|
||||
typedef int32_t (CommAllStatusT)(CommRef *what);
|
||||
typedef int32_t (CommAllControlT)(CommRef *what, int32_t iControl, int32_t iValue, void *pValue);
|
||||
typedef uint32_t (CommAllTickT)(CommRef *what);
|
||||
typedef int32_t (CommAllSendT)(CommRef *what, const void *buffer, int32_t length, uint32_t flags);
|
||||
typedef int32_t (CommAllPeekT)(CommRef *what, void *target, int32_t length, uint32_t *when);
|
||||
typedef int32_t (CommAllRecvT)(CommRef *what, void *target, int32_t length, uint32_t *when);
|
||||
typedef void (CommAllSendCallbackT)(CommRef *what, const void *, int32_t length, uint32_t when);
|
||||
typedef void (CommAllRecvCallbackT)(CommRef *what, void *target, int32_t length, uint32_t when);
|
||||
typedef void (CommAllEventCallbackT)(CommRef *what, int32_t event);
|
||||
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
// known protocol constructors (these also appear in the .h file for the
|
||||
// protocol in question, but are included here for convenience) -- see
|
||||
// protocol .h file for more details
|
||||
|
||||
/*
|
||||
* Construct the class
|
||||
*
|
||||
* entry: maxwid=max record width, maxinp/maxout=input/output packet buffer size
|
||||
* exit: none
|
||||
*/
|
||||
|
||||
#if 0
|
||||
//typedef struct CommUDPRef CommUDPRef;
|
||||
CommRef *CommUDPConstruct(int32_t maxwid, int32_t maxinp, int32_t maxout);
|
||||
|
||||
//typedef struct CommSRPRef CommSRPRef;
|
||||
CommRef *CommSRPConstruct(int32_t maxwid, int32_t maxinp, int32_t maxout);
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _commall_h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
103
src/thirdparty/dirtysdk/include/DirtySDK/comm/commsrp.h
vendored
Normal file
103
src/thirdparty/dirtysdk/include/DirtySDK/comm/commsrp.h
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File commsrp.h
|
||||
|
||||
\Description
|
||||
This is CommSRP (Selectively Reliable Protocol), a datagram packet-based
|
||||
transport class.
|
||||
|
||||
\Copyright
|
||||
Copyright Electronic Arts 1999-2003
|
||||
|
||||
\Version 0.5 01/03/03 (jbrookes) Initial Version, based on CommTCP
|
||||
\Version 0.7 01/07/03 (jbrookes) Working unreliable transport, based on CommUDP
|
||||
\Version 0.8 01/08/03 (jbrookes) Working reliable transport.
|
||||
\Version 0.9 02/09/03 (jbrookes) Added support for sending zero-byte packets, and fixed PS2 alignment issue.
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _commsrp_h
|
||||
#define _commsrp_h
|
||||
|
||||
/*!
|
||||
\Moduledef CommSRP CommSRP
|
||||
\Modulemember Comm
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
// basic reference returned/used by all routines
|
||||
typedef struct CommSRPRef CommSRPRef;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct the class
|
||||
DIRTYCODE_API CommSRPRef *CommSRPConstruct(int32_t maxwid, int32_t maxinp, int32_t maxout);
|
||||
|
||||
// destruct the class
|
||||
DIRTYCODE_API void CommSRPDestroy(CommSRPRef *what);
|
||||
|
||||
// resolve an address
|
||||
DIRTYCODE_API int32_t CommSRPResolve(CommSRPRef *what, const char *addr, char *buf, int32_t len, char div);
|
||||
|
||||
// stop the resolver
|
||||
DIRTYCODE_API void CommSRPUnresolve(CommSRPRef *what);
|
||||
|
||||
// listen for a connection
|
||||
DIRTYCODE_API int32_t CommSRPListen(CommSRPRef *what, const char *addr);
|
||||
|
||||
// stop listening
|
||||
DIRTYCODE_API int32_t CommSRPUnlisten(CommSRPRef *what);
|
||||
|
||||
// initiate a connection to a peer
|
||||
DIRTYCODE_API int32_t CommSRPConnect(CommSRPRef *what, const char *addr);
|
||||
|
||||
// terminate a connection
|
||||
DIRTYCODE_API int32_t CommSRPUnconnect(CommSRPRef *what);
|
||||
|
||||
// set event callback hook
|
||||
DIRTYCODE_API void CommSRPCallback(CommSRPRef *what, void (*callback)(CommRef *ref, int32_t event));
|
||||
|
||||
// return current stream status
|
||||
DIRTYCODE_API int32_t CommSRPStatus(CommSRPRef *what);
|
||||
|
||||
// return current clock tick
|
||||
DIRTYCODE_API uint32_t CommSRPTick(CommSRPRef *what);
|
||||
|
||||
// send a packet
|
||||
DIRTYCODE_API int32_t CommSRPSend(CommSRPRef *what, const void *buffer, int32_t length, uint32_t flags);
|
||||
|
||||
// peek at waiting packet
|
||||
DIRTYCODE_API int32_t CommSRPPeek(CommSRPRef *what, void *target, int32_t length, uint32_t *when);
|
||||
|
||||
// receive a packet from the buffer
|
||||
DIRTYCODE_API int32_t CommSRPRecv(CommSRPRef *what, void *target, int32_t length, uint32_t *when);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _commsrp_h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
120
src/thirdparty/dirtysdk/include/DirtySDK/comm/commudp.h
vendored
Normal file
120
src/thirdparty/dirtysdk/include/DirtySDK/comm/commudp.h
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File commudp.h
|
||||
|
||||
\Description
|
||||
This is a simple UDP transport class which incorporations the notions of virtual
|
||||
connections and error free transfer. The protocol is optimized for use in a real-time
|
||||
environment where latency is more important than bandwidth. Overhead is low with
|
||||
the protocol adding only 8 bytes per packet on top of that required by UDP itself.
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 1999-2003. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 0.1 02/09/99 (GWS) First Version
|
||||
\Version 0.2 02/14/99 (GWS) Revised and enhanced
|
||||
\Version 0.5 02/14/99 (GWS) Alpha release
|
||||
\Version 1.0 07/30/99 (GWS) Final release
|
||||
\Version 2.0 10/27/99 (GWS) Revised to use winsock 1.1/2.0
|
||||
\Version 2.1 12/04/99 (GWS) Removed winsock 1.1 support
|
||||
\Version 2.2 01/12/00 (GWS) Fixed receive tick bug
|
||||
\Version 2.3 06/12/00 (GWS) Added fastack for low-latency nets
|
||||
\Version 2.4 07/07/00 (GWS) Added firewall penetrator
|
||||
\Version 3.0 12/04/00 (GWS) Reported to dirtysock
|
||||
\Version 3.1 11/20/02 (JLB) Added Send() flags parameter
|
||||
\Version 3.2 02/18/03 (JLB) Fixes for multiple connection support
|
||||
\Version 3.3 05/06/03 (GWS) Allowed poke to come from any IP
|
||||
\Version 3.4 09/02/03 (JLB) Added unreliable packet type
|
||||
\Version 4.0 09/12/03 (JLB) Per-send optional unreliable transport
|
||||
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
|
||||
#ifndef _commudp_h
|
||||
#define _commudp_h
|
||||
|
||||
/*!
|
||||
\Moduledef CommUDP CommUDP
|
||||
\Modulemember Comm
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
// basic reference returned/used by all routines
|
||||
typedef struct CommUDPRef CommUDPRef;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct the class
|
||||
DIRTYCODE_API CommUDPRef *CommUDPConstruct(int32_t iMaxWid, int32_t iMaxInp, int32_t iMaxOut);
|
||||
|
||||
// destruct the class
|
||||
DIRTYCODE_API void CommUDPDestroy(CommUDPRef *pRef);
|
||||
|
||||
// resolve an address
|
||||
DIRTYCODE_API int32_t CommUDPResolve(CommUDPRef *pRef, const char *pAddr, char *pBuf, int32_t iLen, char cDiv);
|
||||
|
||||
// resolve an address
|
||||
DIRTYCODE_API void CommUDPUnresolve(CommUDPRef *pRef);
|
||||
|
||||
// listen for a connection
|
||||
DIRTYCODE_API int32_t CommUDPListen(CommUDPRef *pRef, const char *pAddr);
|
||||
|
||||
// stop listening
|
||||
DIRTYCODE_API int32_t CommUDPUnlisten(CommUDPRef *pRef);
|
||||
|
||||
// initiate a connection to a peer
|
||||
DIRTYCODE_API int32_t CommUDPConnect(CommUDPRef *pRef, const char *pAddr);
|
||||
|
||||
// terminate a connection
|
||||
DIRTYCODE_API int32_t CommUDPUnconnect(CommUDPRef *pRef);
|
||||
|
||||
// set event callback hook
|
||||
DIRTYCODE_API void CommUDPCallback(CommUDPRef *pRef, void (*pCallback)(void *pRef, int32_t iEvent));
|
||||
|
||||
// return current stream status
|
||||
DIRTYCODE_API int32_t CommUDPStatus(CommUDPRef *pRef);
|
||||
|
||||
// control connection behavior
|
||||
DIRTYCODE_API int32_t CommUDPControl(CommUDPRef *pRef, int32_t iControl, int32_t iValue, void *pValue);
|
||||
|
||||
// return current clock tick
|
||||
DIRTYCODE_API uint32_t CommUDPTick(CommUDPRef *pRef);
|
||||
|
||||
// send a packet
|
||||
DIRTYCODE_API int32_t CommUDPSend(CommUDPRef *pRef, const void *pBuffer, int32_t iLength, uint32_t uFlags);
|
||||
|
||||
// peek at waiting packet
|
||||
DIRTYCODE_API int32_t CommUDPPeek(CommUDPRef *pRef, void *pTarget, int32_t iLength, uint32_t *pWhen);
|
||||
|
||||
// receive a packet from the buffer
|
||||
DIRTYCODE_API int32_t CommUDPRecv(CommUDPRef *pRef, void *pTarget, int32_t iLength, uint32_t *pWhen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _commudp_h
|
||||
|
92
src/thirdparty/dirtysdk/include/DirtySDK/comm/commudputil.h
vendored
Normal file
92
src/thirdparty/dirtysdk/include/DirtySDK/comm/commudputil.h
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File commudputil.h
|
||||
|
||||
\Description
|
||||
CommUdp knowledge to be shared with gameserver implementation.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2006-2017 Electronic Arts Inc.
|
||||
|
||||
\Version 1.0 09/01/2017 (mclouatre) First Version
|
||||
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
|
||||
#ifndef _commudputil_h
|
||||
#define _commudputil_h
|
||||
|
||||
/*!
|
||||
\Moduledef CommUDP CommUDP
|
||||
\Modulemember Comm
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! define protocol packet types
|
||||
enum {
|
||||
COMMUDP_RAW_PACKET_INIT = 1, // initiate a connection
|
||||
COMMUDP_RAW_PACKET_CONN, // confirm a connection
|
||||
COMMUDP_RAW_PACKET_DISC, // terminate a connection
|
||||
COMMUDP_RAW_PACKET_NAK, // force resend of lost data
|
||||
COMMUDP_RAW_PACKET_POKE, // try and poke through firewall
|
||||
|
||||
COMMUDP_RAW_PACKET_UNREL = 128, // unreliable packet send (must be power of two)
|
||||
// 128-255 reserved for unreliable packet sequence
|
||||
COMMUDP_RAW_PACKET_DATA = 256, // initial data packet sequence number (must be power of two)
|
||||
|
||||
/* Width of the sequence window, can be anything provided
|
||||
RAW_PACKET_DATA + RAW_PACKET_DATA_WINDOW
|
||||
doesn't overlap the meta-data bits. */
|
||||
COMMUDP_RAW_PACKET_DATA_WINDOW = (1 << 24) - 256
|
||||
};
|
||||
|
||||
#define COMMUDP_RAW_METATYPE1_SIZE (8)
|
||||
#define COMMUDP_SEQ_META_SHIFT (28 - 4)
|
||||
#define COMMUDP_SEQ_MULTI_SHIFT (28)
|
||||
#define COMMUDP_SEQ_MULTI_INC (1 << COMMUDP_SEQ_MULTI_SHIFT)
|
||||
#define COMMUDP_SEQ_MASK (0x00ffffff)
|
||||
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Encodes a subpacket size field.
|
||||
DIRTYCODE_API uint32_t CommUDPUtilEncodeSubpacketSize(uint8_t *pBuf, uint32_t uVal);
|
||||
|
||||
// Decodes a subpacket size field (see _CommUDPEncodeSubpacketSize for notes)
|
||||
DIRTYCODE_API uint32_t CommUDPUtilDecodeSubpacketSize(const uint8_t *pBuf, int32_t *pVal);
|
||||
|
||||
// Extracts metatype from host-ordered commupd header seq field (RawUDPPacketT.body.uSeq)
|
||||
DIRTYCODE_API uint32_t CommUDPUtilGetMetaTypeFromSeq(uint32_t uSeq);
|
||||
|
||||
// Returns the metadata size for a given metadata type.
|
||||
DIRTYCODE_API uint32_t CommUDPUtilGetMetaSize(uint32_t uMetaType);
|
||||
|
||||
// Extracts the number of extra subpackets (excluding the main subpacket) from host - ordered commupd header seq field(RawUDPPacketT.body.uSeq)
|
||||
DIRTYCODE_API uint32_t CommUDPUtilGetExtraSubPktCountFromSeq(uint32_t uSeq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _commudputil_h
|
||||
|
97
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptaes.h
vendored
Normal file
97
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptaes.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptaes.h
|
||||
|
||||
\Description
|
||||
An implementation of the AES-128 and AES-256 cipher, based on the FIPS
|
||||
standard, intended for use with the TLS AES cipher suites.
|
||||
|
||||
This implementation deliberately uses the naming conventions from the
|
||||
standard where possible in order to aid comprehension.
|
||||
|
||||
\Notes
|
||||
References:
|
||||
FIPS197 standard: http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2011 Electronic Arts
|
||||
|
||||
\Version 01/20/2011 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptaes_h
|
||||
#define _cryptaes_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptAes CryptAes
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define CRYPTAES_MAXROUNDS (14)
|
||||
|
||||
#define CRYPTAES_KEYTYPE_ENCRYPT (0)
|
||||
#define CRYPTAES_KEYTYPE_DECRYPT (1)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct CryptAesKeyScheduleT
|
||||
{
|
||||
uint16_t uNumRounds;
|
||||
uint16_t uKeyWords;
|
||||
uint32_t aKeySchedule[(CRYPTAES_MAXROUNDS+1)*8];
|
||||
} CryptAesKeyScheduleT;
|
||||
|
||||
// opaque module state
|
||||
typedef struct CryptAesT CryptAesT;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptAesT
|
||||
{
|
||||
CryptAesKeyScheduleT KeySchedule;
|
||||
uint8_t aInitVec[16]; //!< initialization vector/CBC state
|
||||
};
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initialize state for AES encryption/decryption module
|
||||
DIRTYCODE_API void CryptAesInit(CryptAesT *pAes, const uint8_t *pKeyBuf, int32_t iKeyLen, uint32_t uKeyType, const uint8_t *pInitVec);
|
||||
|
||||
// encrypt data with the AES cipher in CBC mode
|
||||
DIRTYCODE_API void CryptAesEncrypt(CryptAesT *pAes, uint8_t *pBuffer, int32_t iLength);
|
||||
|
||||
// decrypt data with the AES cipher in CBC mode
|
||||
DIRTYCODE_API void CryptAesDecrypt(CryptAesT *pAes, uint8_t *pBuffer, int32_t iLength);
|
||||
|
||||
// encrypt a 16 byte data block with AES cipher
|
||||
DIRTYCODE_API void CryptAesEncryptBlock(CryptAesKeyScheduleT *pKeySchedule, const uint8_t *pInput, uint8_t *pOutput);
|
||||
|
||||
// decrypt a 16 byte data block with AES cipher
|
||||
DIRTYCODE_API void CryptAesDecryptBlock(CryptAesKeyScheduleT *pKeySchedule, const uint8_t *pInput, uint8_t *pOutput);
|
||||
|
||||
// initialize AES key schedule
|
||||
DIRTYCODE_API void CryptAesInitKeySchedule(CryptAesKeyScheduleT *pKeySchedule, const uint8_t *pKeyBuf, int32_t iKeyLen, uint32_t uKeyType);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptaes_h
|
102
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptarc4.h
vendored
Normal file
102
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptarc4.h
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File cryptarc4.h
|
||||
|
||||
\Description
|
||||
This module is a from-scratch ARC4 implementation designed to avoid
|
||||
any intellectual property complications. The ARC4 stream cipher is
|
||||
known to produce output that is compatible with the RC4 stream cipher.
|
||||
|
||||
\Notes
|
||||
This algorithm from this cypher was taken from the web site: ciphersaber.gurus.com
|
||||
It is based on the RC4 compatible algorithm that was published in the 2nd ed of
|
||||
the book Applied Cryptography by Bruce Schneier. This is a private-key stream
|
||||
cipher which means that some other secure way of exchanging cipher keys prior
|
||||
to algorithm use is required. Its strength is directly related to the key exchange
|
||||
algorithm strengh. In operation, each individual stream message must use a unique
|
||||
key. This is handled by appending on 10 byte random value onto the private key.
|
||||
This 10-byte data can be sent by public means to the receptor (or included at the
|
||||
start of a file or whatever). When the private key is combined with this public
|
||||
key, it essentially puts the cypher into a random starting state (it is like
|
||||
using a message digest routine to generate a random hash for password comparison).
|
||||
The code below was written from scratch using only a textual algorithm description.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2000-2002
|
||||
|
||||
\Version 1.0 02/25/2000 (gschaefer) First Version
|
||||
\Version 1.1 11/06/2002 (jbrookes) Removed Create()/Destroy() to eliminate mem alloc dependencies.
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _cryptarc4_h
|
||||
#define _cryptarc4_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptArc4 CryptArc4
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct CryptArc4T CryptArc4T;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptArc4T
|
||||
{
|
||||
uint8_t state[256];
|
||||
uint8_t walk;
|
||||
uint8_t swap;
|
||||
};
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create state for ARC4 encryption/decryption module.
|
||||
DIRTYCODE_API void CryptArc4Init(CryptArc4T *pState, const unsigned char *pKeyBuf, int32_t iKeyLen, int32_t iIter);
|
||||
|
||||
// apply the cipher to the data. calling twice undoes the uncryption
|
||||
DIRTYCODE_API void CryptArc4Apply(CryptArc4T *pState, unsigned char *pBuffer, int32_t iLength);
|
||||
|
||||
// advance the cipher state by iLength bytes
|
||||
DIRTYCODE_API void CryptArc4Advance(CryptArc4T *pState, int32_t iLength);
|
||||
|
||||
// encrypt an asciiz string, with a 7-bit asciiz string result
|
||||
DIRTYCODE_API void CryptArc4StringEncrypt(char *pDst, int32_t iLen, const char *pSrc, const uint8_t *pKey, int32_t iKey, int32_t iIter);
|
||||
|
||||
// decrypt an asciiz string, from a 7-bit asciiz encrypted string
|
||||
DIRTYCODE_API void CryptArc4StringDecrypt(char *pDst, int32_t iLen, const char *pSrc, const uint8_t *pKey, int32_t iKey, int32_t iIter);
|
||||
|
||||
#if DIRTYCODE_DEBUG
|
||||
// encryption/decryption helper intended for use with static strings that need to be encrypted in the binary
|
||||
#define CryptArc4StringEncryptStatic(_pStr, _iStrSize, _pKey, _iKeySize, _pStrSrc) CryptArc4StringEncryptStaticCode(_pStr, _iStrSize, _pKey, _iKeySize, _pStrSrc)
|
||||
#else
|
||||
// release version of string encrypt; does not pass source (plaintext) string
|
||||
#define CryptArc4StringEncryptStatic(_pStr, _iStrSize, _pKey, _iKeySize, _pStrSrc) CryptArc4StringEncryptStaticCode(_pStr, _iStrSize, _pKey, _iKeySize, NULL)
|
||||
#endif
|
||||
|
||||
// encryption/decryption helper intended for use with static strings that need to be encrypted in the binary (do not call directly; use CryptArc4StringEncryptStatic() wrapper)
|
||||
DIRTYCODE_API int32_t CryptArc4StringEncryptStaticCode(char *pStr, int32_t iStrSize, const uint8_t *pKey, int32_t iKeySize, const char *pStrSrc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptarc4_h
|
||||
|
156
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptbn.h
vendored
Normal file
156
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptbn.h
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File cryptbn.h
|
||||
|
||||
\Description
|
||||
This module is implements big integer math needed for our cryptography
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 01/18/2017 (eesponda) First version split from CryptRSA
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _cryptbn_h
|
||||
#define _cryptbn_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptBn CryptBn
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **************************************************************************/
|
||||
|
||||
// size of a each unit in the large number
|
||||
#if defined(DIRTYCODE_PC) && DIRTYCODE_64BITPTR == 0
|
||||
#define UCRYPT_SIZE (4)
|
||||
#else
|
||||
#define UCRYPT_SIZE (8)
|
||||
#endif
|
||||
// bits per word
|
||||
#define UCRYPT_BITSIZE (UCRYPT_SIZE*8)
|
||||
// maximum bits of number (add one unit of wiggle room)
|
||||
#define CRYPTBN_MAX_BITS (4096+UCRYPT_BITSIZE)
|
||||
// maximum width of number
|
||||
#define CRYPTBN_MAX_WIDTH (CRYPTBN_MAX_BITS/UCRYPT_BITSIZE)
|
||||
|
||||
/*** Type Definitions *****************************************************************/
|
||||
|
||||
// define crypt types based on UCRYPT_SIZE
|
||||
#if (UCRYPT_SIZE == 4)
|
||||
typedef uint32_t ucrypt_t;
|
||||
#else
|
||||
typedef uint64_t ucrypt_t;
|
||||
#endif
|
||||
|
||||
//! big number state
|
||||
typedef struct CryptBnT
|
||||
{
|
||||
ucrypt_t aData[CRYPTBN_MAX_WIDTH];
|
||||
int32_t iWidth;
|
||||
uint32_t uSign;
|
||||
} CryptBnT;
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init big number state at specific width
|
||||
DIRTYCODE_API void CryptBnInit(CryptBnT *pState, int32_t iWidth);
|
||||
|
||||
// init big number state with an unsigned number
|
||||
DIRTYCODE_API void CryptBnInitSet(CryptBnT *pState, uint32_t uValue);
|
||||
|
||||
// init big number state from a buffer
|
||||
DIRTYCODE_API int32_t CryptBnInitFrom(CryptBnT *pState, int32_t iWidth, const uint8_t *pSource, int32_t iLength);
|
||||
|
||||
// init big number state from a buffer as little-endian
|
||||
DIRTYCODE_API int32_t CryptBnInitLeFrom(CryptBnT *pState, const uint8_t *pSource, int32_t iLength);
|
||||
|
||||
// left shift the big number by a bit
|
||||
DIRTYCODE_API void CryptBnLeftShift(CryptBnT *pState);
|
||||
|
||||
// left shift the big number by multiple bits
|
||||
DIRTYCODE_API void CryptBnLeftShift2(CryptBnT *pState, int32_t iBits);
|
||||
|
||||
// right shift the big number by a bit
|
||||
#define CryptBnRightShift(pState) CryptBnRightShift2(pState, 1)
|
||||
|
||||
// right shift the big number by multiple bits
|
||||
DIRTYCODE_API void CryptBnRightShift2(CryptBnT *pState, int32_t iBits);
|
||||
|
||||
// tests a bit in the big number and returns if it is set
|
||||
DIRTYCODE_API uint8_t CryptBnBitTest(const CryptBnT *pState, int32_t iBit);
|
||||
|
||||
// set a bit in the big number
|
||||
DIRTYCODE_API void CryptBnBitSet(CryptBnT *pState, int32_t iBit);
|
||||
|
||||
// bitwise and two big numbers
|
||||
DIRTYCODE_API void CryptBnBitAnd(CryptBnT *pState, const CryptBnT *pLhs, const CryptBnT *pRhs);
|
||||
|
||||
// bitwise xor two big numbers
|
||||
DIRTYCODE_API void CryptBnBitXor(CryptBnT *pState, const CryptBnT *pLhs, const CryptBnT *pRhs);
|
||||
|
||||
// returns bit length
|
||||
DIRTYCODE_API int32_t CryptBnBitLen(const CryptBnT *pState);
|
||||
|
||||
// returns byte length
|
||||
DIRTYCODE_API int32_t CryptBnByteLen(const CryptBnT *pState);
|
||||
|
||||
// add two big numbers over modulus
|
||||
DIRTYCODE_API void CryptBnModAdd(CryptBnT *pState, const CryptBnT *pAdd1, const CryptBnT *pAdd2, const CryptBnT *pMod);
|
||||
|
||||
// accumulate one big number into another
|
||||
DIRTYCODE_API void CryptBnAccumulate(CryptBnT *pState, const CryptBnT *pAdd);
|
||||
|
||||
// increment the number by 1
|
||||
DIRTYCODE_API void CryptBnIncrement(CryptBnT *pState);
|
||||
|
||||
// subtract two big numbers
|
||||
DIRTYCODE_API void CryptBnSubtract(CryptBnT *pState, const CryptBnT *pSub1, const CryptBnT *pSub2);
|
||||
|
||||
// subtract the number by 1
|
||||
DIRTYCODE_API void CryptBnDecrement(CryptBnT *pState);
|
||||
|
||||
// perform modular multiply operation
|
||||
DIRTYCODE_API void CryptBnModMultiply(CryptBnT *pState, const CryptBnT *pMul1, const CryptBnT *pMul2, const CryptBnT *pMod);
|
||||
|
||||
// multiplication using classical algorithm
|
||||
DIRTYCODE_API void CryptBnMultiply(CryptBnT *pState, const CryptBnT *pMul1, const CryptBnT *pMul2);
|
||||
|
||||
// does a modulus/divide operation using the classical method
|
||||
DIRTYCODE_API void CryptBnMod(const CryptBnT *pDividend, const CryptBnT *pDivisor, CryptBnT *pRemainder, CryptBnT *pQuotient);
|
||||
|
||||
// perform inverse modulo operation
|
||||
DIRTYCODE_API void CryptBnInverseMod(CryptBnT *pState, const CryptBnT *pMod);
|
||||
|
||||
// copy the big number data into output buffer
|
||||
DIRTYCODE_API void CryptBnFinal(const CryptBnT *pState, uint8_t *pResult, int32_t iLength);
|
||||
|
||||
// copy the bit number data into output buffer as little endian
|
||||
DIRTYCODE_API void CryptBnFinalLe(const CryptBnT *pState, uint8_t *pResult, int32_t iLength);
|
||||
|
||||
// copy a big number
|
||||
DIRTYCODE_API void CryptBnClone(CryptBnT *pDst, const CryptBnT *pSrc);
|
||||
|
||||
// print the big number to the log
|
||||
DIRTYCODE_API void CryptBnPrint(const CryptBnT *pState, const char *pTitle);
|
||||
|
||||
// compare two big numbers
|
||||
DIRTYCODE_API int32_t CryptBnCompare(const CryptBnT *pLhs, const CryptBnT *pRhs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptbn_h
|
65
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptchacha.h
vendored
Normal file
65
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptchacha.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptchacha.h
|
||||
|
||||
\Description
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2018 Electronic Arts
|
||||
|
||||
\Version 02/12/2018 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptchacha_h
|
||||
#define _cryptchacha_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptChaCha CryptChaCha
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
// opaque module state
|
||||
typedef struct CryptChaChaT CryptChaChaT;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptChaChaT
|
||||
{
|
||||
uint32_t aInput[16];
|
||||
};
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initialize state for ChaCha encryption/decryption module
|
||||
DIRTYCODE_API void CryptChaChaInit(CryptChaChaT *pChaCha, const uint8_t *pKeyBuf, int32_t iKeyLen);
|
||||
|
||||
// encrypt data with the ChaCha cipher
|
||||
DIRTYCODE_API int32_t CryptChaChaEncrypt(CryptChaChaT *pChaCha, uint8_t *pBuffer, int32_t iLength, const uint8_t *pInitVec, int32_t iIvLen, const uint8_t *pAddData, int32_t iAddLen, uint8_t *pTag, int32_t iTagLen);
|
||||
|
||||
// decrypt data with the ChaCha cipher
|
||||
DIRTYCODE_API int32_t CryptChaChaDecrypt(CryptChaChaT *pChaCha, uint8_t *pBuffer, int32_t iLength, const uint8_t *pInitVec, int32_t iIvLen, const uint8_t *pAddData, int32_t iAddLen, const uint8_t *pTag, int32_t iTagLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptgcm_h
|
98
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptcurve.h
vendored
Normal file
98
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptcurve.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptcurve.h
|
||||
|
||||
\Description
|
||||
This module implements an interface over our different curve crypto APIs
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2018. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptcurve_h
|
||||
#define _cryptcurve_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptCurve CryptCurve
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptbn.h"
|
||||
#include "DirtySDK/crypt/cryptdef.h"
|
||||
#include "DirtySDK/crypt/cryptnist.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
//! maximum state storage we need for diffie hellman
|
||||
#define CRYPTCURVE_DH_MAXSTATE (sizeof(CryptNistDhT))
|
||||
//! maximum state storage we need for digital signature algorithm
|
||||
#define CRYPTCURVE_DSA_MAXSTATE (sizeof(CryptNistDsaT))
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! curve init function
|
||||
typedef int32_t (CryptCurveInitT)(void *pState, int32_t iCurveType);
|
||||
|
||||
//! curve generate public function
|
||||
typedef int32_t (CryptCurvePublicT)(void *pState, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
//! curve generate secret function
|
||||
typedef int32_t (CryptCurveSecretT)(void *pState, CryptEccPointT *pPublicKey, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
//! curve init point
|
||||
typedef int32_t (CryptCurvePointInitT)(CryptEccPointT *pPoint, const uint8_t *pBuffer, int32_t iBufLen);
|
||||
|
||||
//! curve output point to buffer (for dh cases)
|
||||
typedef int32_t (CryptCurvePointFinalT)(void *pState, const CryptEccPointT *pPoint, uint8_t bSecret, uint8_t *pBuffer, int32_t iBufLen);
|
||||
|
||||
//! curve generate dsa signature
|
||||
typedef int32_t (CryptCurveSignT)(void *pState, const CryptBnT *pPrivateKey, const uint8_t *pHash, int32_t iHashSize, CryptEccPointT *pSignature, uint32_t *pCryptUsecs);
|
||||
|
||||
//! curve verify dsa signature
|
||||
typedef int32_t (CryptCurveVerifyT)(void *pState, CryptEccPointT *pPublicKey, const uint8_t *pHash, int32_t iHashSize, CryptEccPointT *pSignature, uint32_t *pCryptUsecs);
|
||||
|
||||
//! interface for dh functionality
|
||||
typedef struct CryptCurveDhT
|
||||
{
|
||||
CryptCurveInitT *Init;
|
||||
CryptCurvePublicT *Public;
|
||||
CryptCurveSecretT *Secret;
|
||||
CryptCurvePointInitT *PointInit;
|
||||
CryptCurvePointFinalT *PointFinal;
|
||||
int32_t iCurveType;
|
||||
} CryptCurveDhT;
|
||||
|
||||
//! interface for dsa functionality
|
||||
typedef struct CryptCurveDsaT
|
||||
{
|
||||
CryptCurveInitT *Init;
|
||||
CryptCurveSignT *Sign;
|
||||
CryptCurveVerifyT *Verify;
|
||||
CryptCurvePointInitT *PointInit;
|
||||
int32_t iCurveType;
|
||||
} CryptCurveDsaT;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// get dh reference and initializes based on curve type
|
||||
DIRTYCODE_API const CryptCurveDhT *CryptCurveGetDh(int32_t iCurveType);
|
||||
|
||||
// get dsa reference and initializes based on curve type
|
||||
DIRTYCODE_API const CryptCurveDsaT *CryptCurveGetDsa(int32_t iCurveType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptcurve_h
|
89
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptdef.h
vendored
Normal file
89
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptdef.h
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
/*H*******************************************************************/
|
||||
/*!
|
||||
\File cryptdef.h
|
||||
|
||||
\Description
|
||||
Common definitions for Crypt modules
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013
|
||||
|
||||
\Version 1.0 11/19/2013 (jbrookes) First Version
|
||||
*/
|
||||
/*******************************************************************H*/
|
||||
|
||||
#ifndef _cryptdef_h
|
||||
#define _cryptdef_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptDef CryptDef
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ***************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptbn.h"
|
||||
|
||||
/*** Defines *********************************************************/
|
||||
|
||||
/*** Macros **********************************************************/
|
||||
|
||||
/*** Type Definitions ************************************************/
|
||||
|
||||
//! a binary large object, such as a modulus or exponent
|
||||
typedef struct CryptBinaryObjT
|
||||
{
|
||||
uint8_t *pObjData;
|
||||
int32_t iObjSize;
|
||||
} CryptBinaryObjT;
|
||||
|
||||
//! used for the point calculations that are used for elliptic curve crypto
|
||||
typedef struct CryptEccPointT
|
||||
{
|
||||
CryptBnT X;
|
||||
CryptBnT Y;
|
||||
} CryptEccPointT;
|
||||
|
||||
//! curve supported groups as per: https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
|
||||
typedef enum CryptCurveE
|
||||
{
|
||||
CRYPTCURVE_UNASSIGNED,
|
||||
CRYPTCURVE_SECT163K1,
|
||||
CRYPTCURVE_SECT163R1,
|
||||
CRYPTCURVE_SECT163R2,
|
||||
CRYPTCURVE_SECT193R1,
|
||||
CRYPTCURVE_SECT193R2,
|
||||
CRYPTCURVE_SECT233K1,
|
||||
CRYPTCURVE_SECT233R1,
|
||||
CRYPTCURVE_SECT239K1,
|
||||
CRYPTCURVE_SECT283K1,
|
||||
CRYPTCURVE_SECT283R1,
|
||||
CRYPTCURVE_SECT409K1,
|
||||
CRYPTCURVE_SECT409R1,
|
||||
CRYPTCURVE_SECT571K1,
|
||||
CRYPTCURVE_SECT571R1,
|
||||
CRYPTCURVE_SECP160K1,
|
||||
CRYPTCURVE_SECP160R1,
|
||||
CRYPTCURVE_SECP160R2,
|
||||
CRYPTCURVE_SECP192K1,
|
||||
CRYPTCURVE_SECP192R1,
|
||||
CRYPTCURVE_SECP224K1,
|
||||
CRYPTCURVE_SECP224R1,
|
||||
CRYPTCURVE_SECP256K1,
|
||||
CRYPTCURVE_SECP256R1,
|
||||
CRYPTCURVE_SECP384R1,
|
||||
CRYPTCURVE_SECP521R1,
|
||||
CRYPTCURVE_BRAINPOOLP256R1,
|
||||
CRYPTCURVE_BRAINPOOLP384R1,
|
||||
CRYPTCURVE_BRAINPOOLP512R1,
|
||||
CRYPTCURVE_X25519,
|
||||
CRYPTCURVE_X448,
|
||||
CRYPTCURVE_MAX = CRYPTCURVE_X448
|
||||
} CryptCurveE;
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptdef_h
|
||||
|
81
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptgcm.h
vendored
Normal file
81
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptgcm.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptgcm.h
|
||||
|
||||
\Description
|
||||
An implementation of the GCM-128 and GCM-256 cipher, based on the NIST
|
||||
standard, intended for use in implementation of TLS1.1 GCM cipher suites.
|
||||
|
||||
This implementation uses Shoup's method utilizing 4-bit tables as described
|
||||
in the GCM specifications. While not particularly fast, table generation
|
||||
is quick and memory usage required small. This implementation is restricted
|
||||
to a feature set suitable for implementation of TLS1.1 GCM cipher suites.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2014 Electronic Arts
|
||||
|
||||
\Version 07/01/2014 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptgcm_h
|
||||
#define _cryptgcm_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptGcm CryptGcm
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptaes.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
// opaque module state
|
||||
typedef struct CryptGcmT CryptGcmT;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptGcmT
|
||||
{
|
||||
uint64_t HL[16]; //!< precalculated htable, low
|
||||
uint64_t HH[16]; //!< precalculated htable, high
|
||||
uint64_t uLen; //!< data length
|
||||
uint64_t uAddLen; //!< additional data length
|
||||
uint8_t aBaseEctr[16]; //!< first ECTR for tag
|
||||
uint8_t aY[16]; //!< y scratch buffer
|
||||
uint8_t aBuf[16]; //!< I/O scratch buffer
|
||||
uint32_t uMode; //!< CRYPTAES_KETYPE_ENCRYPT or CRYPTAES_KEYTYPE_DECRYPT
|
||||
CryptAesKeyScheduleT KeySchedule; //!< AES key schedule
|
||||
};
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initialize state for GCM encryption/decryption module
|
||||
DIRTYCODE_API void CryptGcmInit(CryptGcmT *pGcm, const uint8_t *pKeyBuf, int32_t iKeyLen);
|
||||
|
||||
// encrypt data with the GCM cipher
|
||||
DIRTYCODE_API int32_t CryptGcmEncrypt(CryptGcmT *pGcm, uint8_t *pBuffer, int32_t iLength, const uint8_t *pInitVec, int32_t iIvLen, const uint8_t *pAddData, int32_t iAddLen, uint8_t *pTag, int32_t iTagLen);
|
||||
|
||||
// decrypt data with the GCM cipher
|
||||
DIRTYCODE_API int32_t CryptGcmDecrypt(CryptGcmT *pGcm, uint8_t *pBuffer, int32_t iLength, const uint8_t *pInitVec, int32_t iIvLen, const uint8_t *pAddData, int32_t iAddLen, uint8_t *pTag, int32_t iTagLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptgcm_h
|
98
src/thirdparty/dirtysdk/include/DirtySDK/crypt/crypthash.h
vendored
Normal file
98
src/thirdparty/dirtysdk/include/DirtySDK/crypt/crypthash.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*H*******************************************************************/
|
||||
/*!
|
||||
\File crypthash.h
|
||||
|
||||
\Description
|
||||
This module implements a generic wrapper for all cryptograph
|
||||
hash modules.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013
|
||||
|
||||
\Version 1.0 11/05/2013 (jbrookes) First Version
|
||||
*/
|
||||
/*******************************************************************H*/
|
||||
|
||||
#ifndef _crypthash_h
|
||||
#define _crypthash_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptHash CryptHash
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ***************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptmd5.h"
|
||||
#include "DirtySDK/crypt/cryptsha1.h"
|
||||
#include "DirtySDK/crypt/cryptsha2.h"
|
||||
#include "DirtySDK/util/murmurhash3.h"
|
||||
|
||||
/*** Defines *********************************************************/
|
||||
|
||||
typedef enum CryptHashTypeE
|
||||
{
|
||||
CRYPTHASH_NULL,
|
||||
CRYPTHASH_MURMUR3, //!< murmerhash3; NOT cryto grade but VERY fast, use with caution
|
||||
CRYPTHASH_MD5, //!< MD5; semi-obsolete, use with caution
|
||||
CRYPTHASH_SHA1, //!< SHA1
|
||||
CRYPTHASH_SHA224, //!< SHA2-224
|
||||
CRYPTHASH_SHA256, //!< SHA2-256
|
||||
CRYPTHASH_SHA384, //!< SHA2-384
|
||||
CRYPTHASH_SHA512, //!< SHA2-512
|
||||
CRYPTHASH_NUMHASHES
|
||||
} CryptHashTypeE;
|
||||
|
||||
#define CRYPTHASH_MAXDIGEST (CRYPTSHA2_HASHSIZE_MAX) //!< SHA2 has the largest digest size
|
||||
#define CRYPTHASH_MAXSTATE (sizeof(CryptSha2T)) //!< SHA2 has the largest state
|
||||
|
||||
/*** Macros **********************************************************/
|
||||
|
||||
/*** Type Definitions ************************************************/
|
||||
|
||||
//! crypthash init func
|
||||
typedef void (CryptHashInitT)(void *pState, int32_t iHashSize);
|
||||
|
||||
//! crypthash update func
|
||||
typedef void (CryptHashUpdateT)(void *pState, const uint8_t *pInput, uint32_t uInputLength);
|
||||
|
||||
//! crypthash final func
|
||||
typedef void (CryptHashFinalT)(void *pState, void *pBuffer, uint32_t uLength);
|
||||
|
||||
//! crypthash function block
|
||||
typedef struct CryptHashT
|
||||
{
|
||||
CryptHashInitT *Init;
|
||||
CryptHashUpdateT *Update;
|
||||
CryptHashFinalT *Final;
|
||||
CryptHashTypeE eHashType;
|
||||
int32_t iHashSize;
|
||||
} CryptHashT;
|
||||
|
||||
/*** Variables *******************************************************/
|
||||
|
||||
/*** Functions *******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//!< get reference to hash function
|
||||
DIRTYCODE_API const CryptHashT *CryptHashGet(CryptHashTypeE eHashType);
|
||||
|
||||
//!< get hash size of specified hash function
|
||||
DIRTYCODE_API int32_t CryptHashGetSize(CryptHashTypeE eHashType);
|
||||
|
||||
//!< get hash type based on size of hash (excludes murmurhash3)
|
||||
DIRTYCODE_API CryptHashTypeE CryptHashGetBySize(int32_t iHashSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _crypthash_h
|
||||
|
62
src/thirdparty/dirtysdk/include/DirtySDK/crypt/crypthmac.h
vendored
Normal file
62
src/thirdparty/dirtysdk/include/DirtySDK/crypt/crypthmac.h
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File crypthmac.h
|
||||
|
||||
\Description
|
||||
|
||||
\Notes
|
||||
References:
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2013 Electronic Arts Inc.
|
||||
|
||||
\Version 01/14/2013 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _crypthmac_h
|
||||
#define _crypthmac_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptHmac CryptHmac
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct CryptHmacMsgT
|
||||
{
|
||||
const uint8_t *pMessage;
|
||||
int32_t iMessageLen;
|
||||
} CryptHmacMsgT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// calculate HMAC message digest algorithm
|
||||
DIRTYCODE_API int32_t CryptHmacCalc(uint8_t *pBuffer, int32_t iBufLen, const uint8_t *pMessage, int32_t iMessageLen, const uint8_t *pKey, int32_t iKeyLen, CryptHashTypeE eHashType);
|
||||
|
||||
// calculate HMAC message digest algorithm; this version allows multiple buffers to allow for easy hashing of sparse messages
|
||||
DIRTYCODE_API int32_t CryptHmacCalcMulti(uint8_t *pBuffer, int32_t iBufLen, const CryptHmacMsgT *pMessageList, int32_t iNumMessages, const uint8_t *pKey, int32_t iKeyLen, CryptHashTypeE eHashType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif
|
137
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptmd5.h
vendored
Normal file
137
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptmd5.h
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File cryptmd5.h
|
||||
|
||||
\Description
|
||||
The MD5 message digest algorithm developed by Ron Rivest and documented
|
||||
in RFC1321. This implementation is based on the RFC but does not use the
|
||||
sample code.. It should be free from intellectual property concerns and
|
||||
a reference is included below which further clarifies this point.
|
||||
|
||||
Note that this implementation is limited to hashing no more than 2^32
|
||||
bytes after which its results would be impatible with a fully compliant
|
||||
implementation.
|
||||
|
||||
\Notes
|
||||
http://www.ietf.org/ietf/IPR/RSA-MD-all
|
||||
|
||||
The following was recevied Fenbruary 23,2000
|
||||
From: "Linn, John" <jlinn@rsasecurity.com>
|
||||
|
||||
February 19, 2000
|
||||
|
||||
The purpose of this memo is to clarify the status of intellectual
|
||||
property rights asserted by RSA Security Inc. ("RSA") in the MD2, MD4 and
|
||||
MD5 message-digest algorithms, which are documented in RFC-1319, RFC-1320,
|
||||
and RFC-1321 respectively.
|
||||
|
||||
Implementations of these message-digest algorithms, including
|
||||
implementations derived from the reference C code in RFC-1319, RFC-1320, and
|
||||
RFC-1321, may be made, used, and sold without license from RSA for any
|
||||
purpose.
|
||||
|
||||
No rights other than the ones explicitly set forth above are
|
||||
granted. Further, although RSA grants rights to implement certain
|
||||
algorithms as defined by identified RFCs, including implementations derived
|
||||
from the reference C code in those RFCs, no right to use, copy, sell, or
|
||||
distribute any other implementations of the MD2, MD4, or MD5 message-digest
|
||||
algorithms created, implemented, or distributed by RSA is hereby granted by
|
||||
implication, estoppel, or otherwise. Parties interested in licensing
|
||||
security components and toolkits written by RSA should contact the company
|
||||
to discuss receiving a license. All other questions should be directed to
|
||||
Margaret K. Seif, General Counsel, RSA Security Inc., 36 Crosby Drive,
|
||||
Bedford, Massachusetts 01730.
|
||||
|
||||
Implementations of the MD2, MD4, or MD5 algorithms may be subject to
|
||||
United States laws and regulations controlling the export of technical data,
|
||||
computer software, laboratory prototypes and other commodities (including
|
||||
the Arms Export Control Act, as amended, and the Export Administration Act
|
||||
of 1970). The transfer of certain technical data and commodities may
|
||||
require a license from the cognizant agency of the United States Government.
|
||||
RSA neither represents that a license shall not be required for a particular
|
||||
implementation nor that, if required, one shall be issued.
|
||||
|
||||
|
||||
DISCLAIMER: RSA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
|
||||
OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, VALIDITY OF
|
||||
INTELLECTUAL PROPERTY RIGHTS, ISSUED OR PENDING, OR THE ABSENCE OF LATENT OR
|
||||
OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE, IN CONNECTION WITH THE MD2, MD4,
|
||||
OR MD5 ALGORITHMS. NOTHING IN THIS GRANT OF RIGHTS SHALL BE CONSTRUED AS A
|
||||
REPRESENTATION OR WARRANTY GIVEN BY RSA THAT THE IMPLEMENTATION OF THE
|
||||
ALGORITHM WILL NOT INFRINGE THE INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD
|
||||
PARTY. IN NO EVENT SHALL RSA, ITS TRUSTEES, DIRECTORS, OFFICERS, EMPLOYEES,
|
||||
PARENTS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF
|
||||
ANY KIND RESULTING FROM IMPLEMENTATION OF THIS ALGORITHM, INCLUDING ECONOMIC
|
||||
DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER RSA
|
||||
SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2002. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 03/16/2001 (GWS) First Version
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _cryptmd5_h
|
||||
#define _cryptmd5_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptMD5 CryptMD5
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define MD5_BINARY_OUT 16 //!< length of binary output
|
||||
#define MD5_STRING_OUT 33 //!< length of string output
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct CryptMD5T CryptMD5T;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptMD5T
|
||||
{
|
||||
unsigned char strData[64+8];//!< partial data block (8 for padding)
|
||||
uint32_t uCount; //!< total byte count
|
||||
uint32_t uRegs[4]; //!< the digest registers
|
||||
};
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the MD5 context.
|
||||
DIRTYCODE_API void CryptMD5Init(CryptMD5T *pContext);
|
||||
|
||||
// init the MD5 context (alternate form)
|
||||
DIRTYCODE_API void CryptMD5Init2(CryptMD5T *pContext, int32_t iHashSize);
|
||||
|
||||
// add data to the MD5 context (hash the data).
|
||||
DIRTYCODE_API void CryptMD5Update(CryptMD5T *pContext, const void *pBuffer, int32_t iLength);
|
||||
|
||||
// convert MD5 state into final output form
|
||||
DIRTYCODE_API void CryptMD5Final(CryptMD5T *pContext, void *pBuffer, int32_t iLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptmd5_h
|
||||
|
||||
|
91
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptmont.h
vendored
Normal file
91
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptmont.h
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptmont.h
|
||||
|
||||
\Description
|
||||
This module implements the math for elliptic curve cryptography
|
||||
using montgomery curves
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2018. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptmont_h
|
||||
#define _cryptmont_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptMont CryptMont
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptbn.h"
|
||||
#include "DirtySDK/crypt/cryptdef.h"
|
||||
|
||||
/*** Type Definitions **************************************************************/
|
||||
|
||||
typedef struct CryptMontT
|
||||
{
|
||||
CryptBnT Prime; //!< curve prime
|
||||
CryptBnT PrimeMin2; //!< curve prime - 2 used for exponentiation
|
||||
CryptBnT BasePoint; //!< curve base point (only u)
|
||||
CryptBnT A24; //!< constant used for calculations
|
||||
CryptBnT PrivateKey; //!< private key
|
||||
|
||||
//! working state
|
||||
CryptBnT X_2;
|
||||
CryptBnT X_3;
|
||||
|
||||
CryptEccPointT Result; //!< cached result and z_2/z_3 during the point state
|
||||
|
||||
int32_t iMemGroup; //!< memgroup id
|
||||
void *pMemGroupUserdata; //!< memgroup userdata
|
||||
CryptBnT *pTable; //!< table used for sliding window in exponentiation
|
||||
|
||||
enum
|
||||
{
|
||||
CRYPTMONT_COMPUTE_POINT,//!< calculate the point
|
||||
CRYPTMONT_COMPUTE_EXP //!< calculate the final result
|
||||
} eState; //!< current state of the calculation
|
||||
|
||||
int16_t iBitIndex; //!< bit index for the calculation (private key or exponent)
|
||||
uint8_t bAccumulOne; //!< used to skip the first multiply
|
||||
uint8_t uSwap; //!< current swap state
|
||||
uint32_t uCryptUsecs; //!< total number of usecs the operation took
|
||||
int32_t iCurveType; //!< what curve were we initialized with
|
||||
} CryptMontT;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the curve state
|
||||
DIRTYCODE_API int32_t CryptMontInit(CryptMontT *pState, int32_t iCurveType);
|
||||
|
||||
// for testing-purposes; set the private key
|
||||
DIRTYCODE_API void CryptMontSetPrivateKey(CryptMontT *pState, const uint8_t *pKey);
|
||||
|
||||
// generates a public key based on the curve parameters: BasePoint * Secret
|
||||
DIRTYCODE_API int32_t CryptMontPublic(CryptMontT *pState, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
// generate a shared secret based on the curve parameters and other parties public key: PublicKey * Secret
|
||||
DIRTYCODE_API int32_t CryptMontSecret(CryptMontT *pState, CryptEccPointT *pPublicKey, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
// initialize a point on the curve from a buffer
|
||||
DIRTYCODE_API int32_t CryptMontPointInitFrom(CryptEccPointT *pPoint, const uint8_t *pBuffer, int32_t iBufSize);
|
||||
|
||||
// output a point to a buffer
|
||||
DIRTYCODE_API int32_t CryptMontPointFinal(const CryptMontT *pState, const CryptEccPointT *pPoint, uint8_t bSecret, uint8_t *pBuffer, int32_t iBufSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptmont_h
|
||||
|
116
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptnist.h
vendored
Normal file
116
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptnist.h
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptnist.h
|
||||
|
||||
\Description
|
||||
This module implements the math for elliptic curve cryptography
|
||||
using curves in short Weierstrass form (NIST curves)
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptnist_h
|
||||
#define _cryptnist_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptNist CryptNist
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptbn.h"
|
||||
#include "DirtySDK/crypt/cryptdef.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
//! window size used for sliding window
|
||||
#define CRYPTNIST_WINDOW_SIZE (5)
|
||||
|
||||
//! precomputed table size based on the window size
|
||||
#define CRYPTNIST_TABLE_SIZE (1 << (CRYPTNIST_WINDOW_SIZE - 1))
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! private state that defines the curve
|
||||
typedef struct CryptNistT
|
||||
{
|
||||
CryptBnT Prime; //!< the finite field that the curve is defined over
|
||||
CryptBnT CoefficientA; //!< cofficient that defines the curve
|
||||
CryptBnT CoefficientB; //!< cofficient that defines the curve
|
||||
CryptEccPointT BasePoint; //!< generator point on the curve
|
||||
CryptBnT Order; //!< the number of point operations on the curve until the resultant line is vertical
|
||||
|
||||
int32_t iMemGroup; //!< memgroup id
|
||||
void *pMemGroupUserdata; //!< memgroup userdata
|
||||
CryptEccPointT *pTable; //!< precomputed values used for for computation
|
||||
int32_t iKeyIndex; //!< current bit index state when generating
|
||||
int32_t iSize; //!< size of curve parameters
|
||||
|
||||
uint32_t uCryptUSecs; //!< number of total usecs the operation took
|
||||
} CryptNistT;
|
||||
|
||||
//! state dealing with diffie hellmen key exchange
|
||||
typedef struct CryptNistDhT
|
||||
{
|
||||
CryptNistT Ecc; //!< base ecc state
|
||||
|
||||
CryptBnT PrivateKey; //!< private key used to calculate public key and shared secret
|
||||
CryptEccPointT Result; //!< working state
|
||||
} CryptNistDhT;
|
||||
|
||||
//! state dealing with dsa sign and verify
|
||||
typedef struct CryptNistDsaT
|
||||
{
|
||||
CryptNistT Ecc; //!< base ecc state
|
||||
|
||||
CryptBnT K; //!< secret used for signing operations
|
||||
CryptBnT U1; //!< used for verification operations
|
||||
CryptBnT U2; //!< used for verification operations
|
||||
CryptEccPointT Result; //!< working state
|
||||
} CryptNistDsaT;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initializes the crypt state to perform diffie hellmen key exchange
|
||||
DIRTYCODE_API int32_t CryptNistInitDh(CryptNistDhT *pState, int32_t iCurveType);
|
||||
|
||||
// initializes the crypt state to perform dsa sign and verify
|
||||
DIRTYCODE_API int32_t CryptNistInitDsa(CryptNistDsaT *pState, int32_t iCurveType);
|
||||
|
||||
// generates a public key based on the curve parameters: BasePoint * Secret
|
||||
DIRTYCODE_API int32_t CryptNistPublic(CryptNistDhT *pState, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
// generate a shared secret based on the curve parameters and other parties public key: PublicKey * Secret
|
||||
DIRTYCODE_API int32_t CryptNistSecret(CryptNistDhT *pState, CryptEccPointT *pPublicKey, CryptEccPointT *pResult, uint32_t *pCryptUsecs);
|
||||
|
||||
// generate a ecdsa signature
|
||||
DIRTYCODE_API int32_t CryptNistSign(CryptNistDsaT *pState, const CryptBnT *pPrivateKey, const uint8_t *pHash, int32_t iHashSize, CryptEccPointT *pSignature, uint32_t *pCryptUsecs);
|
||||
|
||||
// verify a ecdsa signature
|
||||
DIRTYCODE_API int32_t CryptNistVerify(CryptNistDsaT *pState, CryptEccPointT *pPublicKey, const uint8_t *pHash, int32_t iHashSize, CryptEccPointT *pSignature, uint32_t *pCryptUsecs);
|
||||
|
||||
// check if the point is on the curve
|
||||
DIRTYCODE_API uint8_t CryptNistPointValidate(const CryptNistDhT *pState, const CryptEccPointT *pPoint);
|
||||
|
||||
// initialize a point on the curve from a buffer
|
||||
DIRTYCODE_API int32_t CryptNistPointInitFrom(CryptEccPointT *pPoint, const uint8_t *pBuffer, int32_t iBufLen);
|
||||
|
||||
// output a point to a buffer (for dh, dsa encoding looks different which we do in protossl)
|
||||
DIRTYCODE_API int32_t CryptNistPointFinal(const CryptNistDhT *pState, const CryptEccPointT *pPoint, uint8_t bSecret, uint8_t *pBuffer, int32_t iBufLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptnist_h
|
53
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptrand.h
vendored
Normal file
53
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptrand.h
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File cryptrand.h
|
||||
|
||||
\Description
|
||||
Cryptographic random number generator. Uses system-defined rng where
|
||||
available.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2012 Electronic Arts Inc.
|
||||
|
||||
\Version 12/05/2012 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _cryptrand_h
|
||||
#define _cryptrand_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptRand CryptRand
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// get random data
|
||||
DIRTYCODE_API void CryptRandGet(uint8_t *pBuffer, int32_t iBufSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptrand_h
|
||||
|
138
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptrsa.h
vendored
Normal file
138
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptrsa.h
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File cryptrsa.h
|
||||
|
||||
\Description
|
||||
This module is a from-scratch RSA implementation in order to avoid any
|
||||
intellectual property issues. The 1024 bit RSA public key encryption algorithm
|
||||
was implemented from a specification provided by Netscape for SSL implementation
|
||||
(see protossl.h).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2002. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 03/08/2002 (gschaefer) First Version (protossl)
|
||||
\Version 11/18/2002 (jbrookes) Names changed to include "Proto"
|
||||
\Version 03/05/2003 (jbrookes) Split RSA encryption from protossl
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _cryptrsa_h
|
||||
#define _cryptrsa_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptRSA CryptRSA
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptbn.h"
|
||||
#include "DirtySDK/crypt/cryptdef.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! union of our working state depending on the type of operations
|
||||
typedef union CryptRSAWorkingT
|
||||
{
|
||||
struct
|
||||
{
|
||||
CryptBnT Modulus; //!< public key modulus
|
||||
CryptBnT Exponent; //!< public key exponent
|
||||
|
||||
// working memory for modular exponentiation
|
||||
CryptBnT Powerof;
|
||||
CryptBnT Accumul;
|
||||
} PublicKey;
|
||||
|
||||
struct
|
||||
{
|
||||
/* selected private key state we use for chinese remainder theorum computation
|
||||
we have access to the other data (modulus, exponent) but it is not used so
|
||||
not worth storing */
|
||||
CryptBnT PrimeP; //!< prime factor p of modulus
|
||||
CryptBnT PrimeQ; //!< prime factor q of modulus
|
||||
CryptBnT ExponentP; //!< exponent dP mod p-1
|
||||
CryptBnT ExponentQ; //!< exponent dQ mod q-1
|
||||
CryptBnT Coeffecient; //!< inverse of q mod p
|
||||
|
||||
// working memory for modular exponentiation
|
||||
CryptBnT PowerofP;
|
||||
CryptBnT PowerofQ;
|
||||
CryptBnT M1;
|
||||
CryptBnT M2;
|
||||
|
||||
// current state of computation
|
||||
enum
|
||||
{
|
||||
CRT_COMPUTE_M1,
|
||||
CRT_COMPUTE_M2
|
||||
} eState;
|
||||
} PrivateKey;
|
||||
} CryptRSAWorkingT;
|
||||
|
||||
//! cryptrsa state
|
||||
typedef struct CryptRSAT
|
||||
{
|
||||
CryptRSAWorkingT Working; //!< working state & data for doing modular exponentiation
|
||||
|
||||
CryptBnT *pTable; //!< table used in sliding window for precomputed powers
|
||||
CryptBnT aTable[1]; //!< fixed sized table used for public key operations which is our base case
|
||||
|
||||
// memory allocation data
|
||||
int32_t iMemGroup;
|
||||
void *pMemGroupUserData;
|
||||
|
||||
int32_t iKeyModSize; //!< size of public key modulus
|
||||
uint8_t EncryptBlock[1024]; //!< input/output data
|
||||
|
||||
int16_t iExpBitIndex; //!< bit index into the current exponent we are working on
|
||||
uint8_t bAccumulOne; //!< can we skip the first multiply?
|
||||
uint8_t bPrivate; //!< are we public or private key operation?
|
||||
|
||||
// rsa profiling info
|
||||
uint32_t uCryptMsecs;
|
||||
uint32_t uCryptUsecs;
|
||||
uint32_t uNumExpCalls;
|
||||
} CryptRSAT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init rsa state
|
||||
DIRTYCODE_API int32_t CryptRSAInit(CryptRSAT *pState, const uint8_t *pModulus, int32_t iModSize, const uint8_t *pExponent, int32_t iExpSize);
|
||||
|
||||
// init rsa state for private key data
|
||||
DIRTYCODE_API int32_t CryptRSAInit2(CryptRSAT *pState, int32_t iModSize, const CryptBinaryObjT *pPrimeP, const CryptBinaryObjT *pPrimeQ, const CryptBinaryObjT *pExponentP, const CryptBinaryObjT *pExponentQ, const CryptBinaryObjT *pCoeffecient);
|
||||
|
||||
// setup the master shared secret for encryption
|
||||
DIRTYCODE_API void CryptRSAInitMaster(CryptRSAT *pState, const uint8_t *pMaster, int32_t iMasterLen);
|
||||
|
||||
// setup the master shared secret for encryption using PKCS1.5
|
||||
DIRTYCODE_API void CryptRSAInitPrivate(CryptRSAT *pState, const uint8_t *pMaster, int32_t iMasterLen);
|
||||
|
||||
// setup the encrypted signature for decryption.
|
||||
DIRTYCODE_API void CryptRSAInitSignature(CryptRSAT *pState, const uint8_t *pSig, int32_t iSigLen);
|
||||
|
||||
// do the encryption/decryption
|
||||
DIRTYCODE_API int32_t CryptRSAEncrypt(CryptRSAT *pState, int32_t iIter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptrsa_h
|
||||
|
84
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptsha1.h
vendored
Normal file
84
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptsha1.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/*H*******************************************************************/
|
||||
/*!
|
||||
\File cryptsha1.h
|
||||
|
||||
\Description
|
||||
This module implements SHA1 as defined in RFC 3174.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2004. ALL RIGHTS RESERVED.
|
||||
|
||||
\Notes
|
||||
The implementation is based on the algorithm description in sections
|
||||
3 through 6 of RFC 3174 and not on the C code in section 7.
|
||||
|
||||
The code deliberately uses some of the naming conventions from
|
||||
the RFC to in order to aid comprehension.
|
||||
|
||||
This implementation is limited to hashing no more than 2^32-9 bytes.
|
||||
It will silently produce the wrong result if an attempt is made to
|
||||
hash more data.
|
||||
|
||||
\Version 1.0 06/06/2004 (sbevan) First Version
|
||||
*/
|
||||
/*******************************************************************H*/
|
||||
|
||||
#ifndef _cryptsha1_h
|
||||
#define _cryptsha1_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptSha1 CryptSha1
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ***************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines *********************************************************/
|
||||
|
||||
#define CRYPTSHA1_HASHSIZE (160/8) //!< length of SHA1 hash
|
||||
|
||||
/*** Macros **********************************************************/
|
||||
|
||||
/*** Type Definitions ************************************************/
|
||||
|
||||
typedef struct CryptSha1T CryptSha1T;
|
||||
|
||||
//! all fields are PRIVATE
|
||||
struct CryptSha1T
|
||||
{
|
||||
uint32_t uCount; //!< total length of hash data in bytes
|
||||
uint32_t uPartialCount; //!< # bytes in the strData
|
||||
uint32_t H[5]; //!< message digest
|
||||
uint8_t strData[16*4]; //!< partial data block
|
||||
};
|
||||
|
||||
/*** Variables *******************************************************/
|
||||
|
||||
/*** Functions *******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the SHA1 context.
|
||||
DIRTYCODE_API void CryptSha1Init(CryptSha1T *pSha1);
|
||||
|
||||
// init the SHA1 context (alternate form)
|
||||
DIRTYCODE_API void CryptSha1Init2(CryptSha1T *pSha1, int32_t iHashSize);
|
||||
|
||||
// add data to the SHA1 context (hash the data).
|
||||
DIRTYCODE_API void CryptSha1Update(CryptSha1T *pSha1, const uint8_t *pInput, uint32_t uInputLength);
|
||||
|
||||
// convert SHA1 state into final output form
|
||||
DIRTYCODE_API void CryptSha1Final(CryptSha1T *pSha1, void *pBuffer, uint32_t uLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif
|
87
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptsha2.h
vendored
Normal file
87
src/thirdparty/dirtysdk/include/DirtySDK/crypt/cryptsha2.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
/*H*******************************************************************/
|
||||
/*!
|
||||
\File cryptsha2.h
|
||||
|
||||
\Description
|
||||
This module implements SHA2 as defined in RFC 6234, which is
|
||||
itself based on FIPS 180-2.
|
||||
|
||||
\Notes
|
||||
This implementation is limited to hashing no more than 2^32-9
|
||||
bytes. It will silently produce the wrong result if an attempt
|
||||
is made to hash more data.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013
|
||||
|
||||
\Version 1.0 11/04/2013 (jbrookes) First Version
|
||||
*/
|
||||
/*******************************************************************H*/
|
||||
|
||||
#ifndef _cryptsha2_h
|
||||
#define _cryptsha2_h
|
||||
|
||||
/*!
|
||||
\Moduledef CryptSha2 CryptSha2
|
||||
\Modulemember Crypt
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ***************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines *********************************************************/
|
||||
|
||||
//! maximum hash result
|
||||
#define CRYPTSHA224_HASHSIZE (28)
|
||||
#define CRYPTSHA256_HASHSIZE (32)
|
||||
#define CRYPTSHA384_HASHSIZE (48)
|
||||
#define CRYPTSHA512_HASHSIZE (64)
|
||||
#define CRYPTSHA2_HASHSIZE_MAX (CRYPTSHA512_HASHSIZE)
|
||||
|
||||
/*** Macros **********************************************************/
|
||||
|
||||
/*** Type Definitions ************************************************/
|
||||
|
||||
//! private SHA2 state
|
||||
typedef struct CryptSha2T
|
||||
{
|
||||
uint32_t uCount; //!< total length of hash data in bytes
|
||||
uint8_t uHashSize; //!< hash size
|
||||
uint8_t uBlockSize; //!< 64/128 depending on mode
|
||||
uint8_t uPartialCount; //!< # bytes in the partial data block
|
||||
uint8_t _pad;
|
||||
union
|
||||
{
|
||||
uint32_t H_32[8];
|
||||
uint64_t H_64[8];
|
||||
}TempHash; //!< temporary hash state
|
||||
uint8_t strData[128]; //!< partial data block
|
||||
} CryptSha2T;
|
||||
|
||||
/*** Variables *******************************************************/
|
||||
|
||||
/*** Functions *******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the SHA2 context.
|
||||
DIRTYCODE_API void CryptSha2Init(CryptSha2T *pSha2, int32_t iHashSize);
|
||||
|
||||
// add data to the SHA2 context (hash the data).
|
||||
DIRTYCODE_API void CryptSha2Update(CryptSha2T *pSha2, const uint8_t *pInput, uint32_t uInputLength);
|
||||
|
||||
// convert SHA2 state into final output form
|
||||
DIRTYCODE_API void CryptSha2Final(CryptSha2T *pSha2, uint8_t *pBuffer, uint32_t uLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _cryptsha2_h
|
||||
|
49
src/thirdparty/dirtysdk/include/DirtySDK/dirtydefs.h
vendored
Normal file
49
src/thirdparty/dirtysdk/include/DirtySDK/dirtydefs.h
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
|
||||
\File dirtydefs.h
|
||||
|
||||
\Description:
|
||||
DirtySock platform independent definitions and enumerations.
|
||||
|
||||
[DEPRECATE]
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 1999-2005
|
||||
|
||||
\Version 1.0 02/03/99 (JLB) First Version
|
||||
\Version 1.1 04/01/99 (MDB) Added Endian types
|
||||
\Version 1.2 03/27/02 (GWS) Made NULL C++ friendly, added DIRTYCODE_IOP, CODE_UNIX
|
||||
\Version 1.3 02/22/05 (JEF) Moved CODE_XXX to DIRTYCODE_XXX to avoid conflicts
|
||||
\Version 1.4 03/22/05 (GWS) Replaced with include of platform.h
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtydefs_h
|
||||
#define _dirtydefs_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// Microsoft Facilty codes when building a HRESTULT go up to 81, so we'll just start at 128
|
||||
// we have 11 bits to work with giving us a max value of 2047
|
||||
#define DIRTYAPI_SOCKET (128)
|
||||
#define DIRTYAPI_PROTO_HTTP (129)
|
||||
#define DIRTYAPI_PROTO_SSL (130)
|
||||
#define DIRTYAPI_QOS (131)
|
||||
#define DIRTYAPI_MAX (2047)
|
||||
|
||||
#define DIRTYAPI_SOCKET_ERR_ALREADY_ACTIVE (-1)
|
||||
#define DIRTYAPI_SOCKET_ERR_NO_MEMORY (-2)
|
||||
#define DIRTYAPI_SOCKET_ERR_HOST_NAME_CACHE (-3)
|
||||
#define DIRTYAPI_SOCKET_ERR_PLATFORM_SPECIFIC (-4)
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
#endif // _dirtydefs_h
|
||||
|
||||
|
746
src/thirdparty/dirtysdk/include/DirtySDK/dirtylang.h
vendored
Normal file
746
src/thirdparty/dirtysdk/include/DirtySDK/dirtylang.h
vendored
Normal file
@ -0,0 +1,746 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtylang.h
|
||||
|
||||
\Description
|
||||
Country and Language Code Information
|
||||
|
||||
\Notes
|
||||
This module provides country and language codes for both client and
|
||||
server code in DirtySDK.
|
||||
2-letter language codes are currently available here:
|
||||
http://en.wikipedia.org/wiki/ISO_639
|
||||
2-letter country codes are currently available here:
|
||||
http://en.wikipedia.org/wiki/ISO_3166
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2004. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 11/30/2004 (jfrank) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtylang_h
|
||||
#define _dirtylang_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyLang DirtyLang
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
//! Commonly used locality values
|
||||
#define LOBBYAPI_LOCALITY_UNKNOWN ('zzZZ')
|
||||
#define LOBBYAPI_LOCALITY_EN_US ('enUS')
|
||||
#define LOBBYAPI_LOCALITY_BLANK ('\0\0\0\0')
|
||||
#define LOBBYAPI_LOCALITY_WILDCARD ('****')
|
||||
|
||||
#define LOBBYAPI_LOCALITY_DEFAULT LOBBYAPI_LOCALITY_EN_US
|
||||
#define LOBBYAPI_LOCALITY_DEFAULT_STR "enUS"
|
||||
#define LOBBYAPI_LOCALITY_UNKNOWN_STR "zzZZ"
|
||||
|
||||
//! Non-specific, commonly used country and language codes
|
||||
#define LOBBYAPI_LANGUAGE_UNKNOWN ('zz')
|
||||
#define LOBBYAPI_COUNTRY_UNKNOWN ('ZZ')
|
||||
#define LOBBYAPI_LANGUAGE_WILDCARD ('**')
|
||||
#define LOBBYAPI_COUNTRY_WILDCARD ('**')
|
||||
#define LOBBYAPI_LANGUAGE_UNKNOWN_STR ("zz")
|
||||
#define LOBBYAPI_COUNTRY_UNKNOWN_STR ("ZZ")
|
||||
|
||||
//! Languages
|
||||
#define LOBBYAPI_LANGUAGE_AFAN_OROMO ('om')
|
||||
#define LOBBYAPI_LANGUAGE_ABKHAZIAN ('ab')
|
||||
#define LOBBYAPI_LANGUAGE_AFAR ('aa')
|
||||
#define LOBBYAPI_LANGUAGE_AFRIKAANS ('af')
|
||||
#define LOBBYAPI_LANGUAGE_ALBANIAN ('sq')
|
||||
#define LOBBYAPI_LANGUAGE_AMHARIC ('am')
|
||||
#define LOBBYAPI_LANGUAGE_ARABIC ('ar')
|
||||
#define LOBBYAPI_LANGUAGE_ARMENIAN ('hy')
|
||||
#define LOBBYAPI_LANGUAGE_ASSAMESE ('as')
|
||||
#define LOBBYAPI_LANGUAGE_AYMARA ('ay')
|
||||
#define LOBBYAPI_LANGUAGE_AZERBAIJANI ('az')
|
||||
#define LOBBYAPI_LANGUAGE_BASHKIR ('ba')
|
||||
#define LOBBYAPI_LANGUAGE_BASQUE ('eu')
|
||||
#define LOBBYAPI_LANGUAGE_BENGALI ('bn')
|
||||
#define LOBBYAPI_LANGUAGE_BHUTANI ('dz')
|
||||
#define LOBBYAPI_LANGUAGE_BIHARI ('bh')
|
||||
#define LOBBYAPI_LANGUAGE_BISLAMA ('bi')
|
||||
#define LOBBYAPI_LANGUAGE_BRETON ('br')
|
||||
#define LOBBYAPI_LANGUAGE_BULGARIAN ('bg')
|
||||
#define LOBBYAPI_LANGUAGE_BURMESE ('my')
|
||||
#define LOBBYAPI_LANGUAGE_BYELORUSSIAN ('be')
|
||||
#define LOBBYAPI_LANGUAGE_CAMBODIAN ('km')
|
||||
#define LOBBYAPI_LANGUAGE_CATALAN ('ca')
|
||||
#define LOBBYAPI_LANGUAGE_CHINESE ('zh')
|
||||
#define LOBBYAPI_LANGUAGE_CORSICAN ('co')
|
||||
#define LOBBYAPI_LANGUAGE_CROATIAN ('hr')
|
||||
#define LOBBYAPI_LANGUAGE_CZECH ('cs')
|
||||
#define LOBBYAPI_LANGUAGE_DANISH ('da')
|
||||
#define LOBBYAPI_LANGUAGE_DUTCH ('nl')
|
||||
#define LOBBYAPI_LANGUAGE_ENGLISH ('en')
|
||||
#define LOBBYAPI_LANGUAGE_ESPERANTO ('eo')
|
||||
#define LOBBYAPI_LANGUAGE_ESTONIAN ('et')
|
||||
#define LOBBYAPI_LANGUAGE_FAEROESE ('fo')
|
||||
#define LOBBYAPI_LANGUAGE_FIJI ('fj')
|
||||
#define LOBBYAPI_LANGUAGE_FINNISH ('fi')
|
||||
#define LOBBYAPI_LANGUAGE_FRENCH ('fr')
|
||||
#define LOBBYAPI_LANGUAGE_FRISIAN ('fy')
|
||||
#define LOBBYAPI_LANGUAGE_GALICIAN ('gl')
|
||||
#define LOBBYAPI_LANGUAGE_GEORGIAN ('ka')
|
||||
#define LOBBYAPI_LANGUAGE_GERMAN ('de')
|
||||
#define LOBBYAPI_LANGUAGE_GREEK ('el')
|
||||
#define LOBBYAPI_LANGUAGE_GREENLANDIC ('kl')
|
||||
#define LOBBYAPI_LANGUAGE_GUARANI ('gn')
|
||||
#define LOBBYAPI_LANGUAGE_GUJARATI ('gu')
|
||||
#define LOBBYAPI_LANGUAGE_HAUSA ('ha')
|
||||
#define LOBBYAPI_LANGUAGE_HEBREW ('he')
|
||||
#define LOBBYAPI_LANGUAGE_HINDI ('hi')
|
||||
#define LOBBYAPI_LANGUAGE_HUNGARIAN ('hu')
|
||||
#define LOBBYAPI_LANGUAGE_ICELANDIC ('is')
|
||||
#define LOBBYAPI_LANGUAGE_INDONESIAN ('id')
|
||||
#define LOBBYAPI_LANGUAGE_INTERLINGUA ('ia')
|
||||
#define LOBBYAPI_LANGUAGE_INTERLINGUE ('ie')
|
||||
#define LOBBYAPI_LANGUAGE_INUPIAK ('ik')
|
||||
#define LOBBYAPI_LANGUAGE_INUKTITUT ('iu')
|
||||
#define LOBBYAPI_LANGUAGE_IRISH ('ga')
|
||||
#define LOBBYAPI_LANGUAGE_ITALIAN ('it')
|
||||
#define LOBBYAPI_LANGUAGE_JAPANESE ('ja')
|
||||
#define LOBBYAPI_LANGUAGE_JAVANESE ('jw')
|
||||
#define LOBBYAPI_LANGUAGE_KANNADA ('kn')
|
||||
#define LOBBYAPI_LANGUAGE_KASHMIRI ('ks')
|
||||
#define LOBBYAPI_LANGUAGE_KAZAKH ('kk')
|
||||
#define LOBBYAPI_LANGUAGE_KINYARWANDA ('rw')
|
||||
#define LOBBYAPI_LANGUAGE_KIRGHIZ ('ky')
|
||||
#define LOBBYAPI_LANGUAGE_KIRUNDI ('rn')
|
||||
#define LOBBYAPI_LANGUAGE_KOREAN ('ko')
|
||||
#define LOBBYAPI_LANGUAGE_KURDISH ('ku')
|
||||
#define LOBBYAPI_LANGUAGE_LAOTHIAN ('lo')
|
||||
#define LOBBYAPI_LANGUAGE_LATIN ('la')
|
||||
#define LOBBYAPI_LANGUAGE_LATVIAN_LETTISH ('lv')
|
||||
#define LOBBYAPI_LANGUAGE_LINGALA ('ln')
|
||||
#define LOBBYAPI_LANGUAGE_LITHUANIAN ('lt')
|
||||
#define LOBBYAPI_LANGUAGE_MACEDONIAN ('mk')
|
||||
#define LOBBYAPI_LANGUAGE_MALAGASY ('mg')
|
||||
#define LOBBYAPI_LANGUAGE_MALAY ('ms')
|
||||
#define LOBBYAPI_LANGUAGE_MALAYALAM ('ml')
|
||||
#define LOBBYAPI_LANGUAGE_MALTESE ('mt')
|
||||
#define LOBBYAPI_LANGUAGE_MAORI ('mi')
|
||||
#define LOBBYAPI_LANGUAGE_MARATHI ('mr')
|
||||
#define LOBBYAPI_LANGUAGE_MOLDAVIAN ('mo')
|
||||
#define LOBBYAPI_LANGUAGE_MONGOLIAN ('mn')
|
||||
#define LOBBYAPI_LANGUAGE_NAURU ('na')
|
||||
#define LOBBYAPI_LANGUAGE_NEPALI ('ne')
|
||||
#define LOBBYAPI_LANGUAGE_NORWEGIAN ('no')
|
||||
#define LOBBYAPI_LANGUAGE_OCCITAN ('oc')
|
||||
#define LOBBYAPI_LANGUAGE_ORIYA ('or')
|
||||
#define LOBBYAPI_LANGUAGE_PASHTO_PUSHTO ('ps')
|
||||
#define LOBBYAPI_LANGUAGE_PERSIAN ('fa')
|
||||
#define LOBBYAPI_LANGUAGE_POLISH ('pl')
|
||||
#define LOBBYAPI_LANGUAGE_PORTUGUESE ('pt')
|
||||
#define LOBBYAPI_LANGUAGE_PUNJABI ('pa')
|
||||
#define LOBBYAPI_LANGUAGE_QUECHUA ('qu')
|
||||
#define LOBBYAPI_LANGUAGE_RHAETO_ROMANCE ('rm')
|
||||
#define LOBBYAPI_LANGUAGE_ROMANIAN ('ro')
|
||||
#define LOBBYAPI_LANGUAGE_RUSSIAN ('ru')
|
||||
#define LOBBYAPI_LANGUAGE_SAMOAN ('sm')
|
||||
#define LOBBYAPI_LANGUAGE_SANGRO ('sg')
|
||||
#define LOBBYAPI_LANGUAGE_SANSKRIT ('sa')
|
||||
#define LOBBYAPI_LANGUAGE_SCOTS_GAELIC ('gd')
|
||||
#define LOBBYAPI_LANGUAGE_SERBIAN ('sr')
|
||||
#define LOBBYAPI_LANGUAGE_SERBO_CROATIAN ('sh')
|
||||
#define LOBBYAPI_LANGUAGE_SESOTHO ('st')
|
||||
#define LOBBYAPI_LANGUAGE_SETSWANA ('tn')
|
||||
#define LOBBYAPI_LANGUAGE_SHONA ('sn')
|
||||
#define LOBBYAPI_LANGUAGE_SINDHI ('sd')
|
||||
#define LOBBYAPI_LANGUAGE_SINGHALESE ('si')
|
||||
#define LOBBYAPI_LANGUAGE_SISWATI ('ss')
|
||||
#define LOBBYAPI_LANGUAGE_SLOVAK ('sk')
|
||||
#define LOBBYAPI_LANGUAGE_SLOVENIAN ('sl')
|
||||
#define LOBBYAPI_LANGUAGE_SOMALI ('so')
|
||||
#define LOBBYAPI_LANGUAGE_SPANISH ('es')
|
||||
#define LOBBYAPI_LANGUAGE_SUDANESE ('su')
|
||||
#define LOBBYAPI_LANGUAGE_SWAHILI ('sw')
|
||||
#define LOBBYAPI_LANGUAGE_SWEDISH ('sv')
|
||||
#define LOBBYAPI_LANGUAGE_TAGALOG ('tl')
|
||||
#define LOBBYAPI_LANGUAGE_TAJIK ('tg')
|
||||
#define LOBBYAPI_LANGUAGE_TAMIL ('ta')
|
||||
#define LOBBYAPI_LANGUAGE_TATAR ('tt')
|
||||
#define LOBBYAPI_LANGUAGE_TELUGU ('te')
|
||||
#define LOBBYAPI_LANGUAGE_THAI ('th')
|
||||
#define LOBBYAPI_LANGUAGE_TIBETAN ('bo')
|
||||
#define LOBBYAPI_LANGUAGE_TIGRINYA ('ti')
|
||||
#define LOBBYAPI_LANGUAGE_TONGA ('to')
|
||||
#define LOBBYAPI_LANGUAGE_TSONGA ('ts')
|
||||
#define LOBBYAPI_LANGUAGE_TURKISH ('tr')
|
||||
#define LOBBYAPI_LANGUAGE_TURKMEN ('tk')
|
||||
#define LOBBYAPI_LANGUAGE_TWI ('tw')
|
||||
#define LOBBYAPI_LANGUAGE_UIGHUR ('ug')
|
||||
#define LOBBYAPI_LANGUAGE_UKRAINIAN ('uk')
|
||||
#define LOBBYAPI_LANGUAGE_URDU ('ur')
|
||||
#define LOBBYAPI_LANGUAGE_UZBEK ('uz')
|
||||
#define LOBBYAPI_LANGUAGE_VIETNAMESE ('vi')
|
||||
#define LOBBYAPI_LANGUAGE_VOLAPUK ('vo')
|
||||
#define LOBBYAPI_LANGUAGE_WELSH ('cy')
|
||||
#define LOBBYAPI_LANGUAGE_WOLOF ('wo')
|
||||
#define LOBBYAPI_LANGUAGE_XHOSA ('xh')
|
||||
#define LOBBYAPI_LANGUAGE_YIDDISH ('yi')
|
||||
#define LOBBYAPI_LANGUAGE_YORUBA ('yo')
|
||||
#define LOBBYAPI_LANGUAGE_ZHUANG ('za')
|
||||
#define LOBBYAPI_LANGUAGE_ZULU ('zu')
|
||||
|
||||
// Languages: added on Mar-25-2011 according to ISO 639-1
|
||||
#define LOBBYAPI_LANGUAGE_BOSNIAN ('bs')
|
||||
#define LOBBYAPI_LANGUAGE_DIVEHI ('dv')
|
||||
#define LOBBYAPI_LANGUAGE_IGBO ('ig')
|
||||
#define LOBBYAPI_LANGUAGE_LUXEMBOURGISH ('lb')
|
||||
#define LOBBYAPI_LANGUAGE_YI ('ii')
|
||||
#define LOBBYAPI_LANGUAGE_NORWEGIAN_BOKMAL ('nb')
|
||||
#define LOBBYAPI_LANGUAGE_NORWEGIAN_NYNORSK ('nn')
|
||||
#define LOBBYAPI_LANGUAGE_SAMI ('se')
|
||||
|
||||
// Default language
|
||||
#define LOBBYAPI_LANGUAGE_DEFAULT LOBBYAPI_LANGUAGE_ENGLISH
|
||||
#define LOBBYAPI_LANGUAGE_DEFAULT_STR "en"
|
||||
|
||||
//! Countries
|
||||
#define LOBBYAPI_COUNTRY_AFGHANISTAN ('AF')
|
||||
#define LOBBYAPI_COUNTRY_ALBANIA ('AL')
|
||||
#define LOBBYAPI_COUNTRY_ALGERIA ('DZ')
|
||||
#define LOBBYAPI_COUNTRY_AMERICAN_SAMOA ('AS')
|
||||
#define LOBBYAPI_COUNTRY_ANDORRA ('AD')
|
||||
#define LOBBYAPI_COUNTRY_ANGOLA ('AO')
|
||||
#define LOBBYAPI_COUNTRY_ANGUILLA ('AI')
|
||||
#define LOBBYAPI_COUNTRY_ANTARCTICA ('AQ')
|
||||
#define LOBBYAPI_COUNTRY_ANTIGUA_BARBUDA ('AG')
|
||||
#define LOBBYAPI_COUNTRY_ARGENTINA ('AR')
|
||||
#define LOBBYAPI_COUNTRY_ARMENIA ('AM')
|
||||
#define LOBBYAPI_COUNTRY_ARUBA ('AW')
|
||||
#define LOBBYAPI_COUNTRY_AUSTRALIA ('AU')
|
||||
#define LOBBYAPI_COUNTRY_AUSTRIA ('AT')
|
||||
#define LOBBYAPI_COUNTRY_AZERBAIJAN ('AZ')
|
||||
#define LOBBYAPI_COUNTRY_BAHAMAS ('BS')
|
||||
#define LOBBYAPI_COUNTRY_BAHRAIN ('BH')
|
||||
#define LOBBYAPI_COUNTRY_BANGLADESH ('BD')
|
||||
#define LOBBYAPI_COUNTRY_BARBADOS ('BB')
|
||||
#define LOBBYAPI_COUNTRY_BELARUS ('BY')
|
||||
#define LOBBYAPI_COUNTRY_BELGIUM ('BE')
|
||||
#define LOBBYAPI_COUNTRY_BELIZE ('BZ')
|
||||
#define LOBBYAPI_COUNTRY_BENIN ('BJ')
|
||||
#define LOBBYAPI_COUNTRY_BERMUDA ('BM')
|
||||
#define LOBBYAPI_COUNTRY_BHUTAN ('BT')
|
||||
#define LOBBYAPI_COUNTRY_BOLIVIA ('BO')
|
||||
#define LOBBYAPI_COUNTRY_BOSNIA_HERZEGOVINA ('BA')
|
||||
#define LOBBYAPI_COUNTRY_BOTSWANA ('BW')
|
||||
#define LOBBYAPI_COUNTRY_BOUVET_ISLAND ('BV')
|
||||
#define LOBBYAPI_COUNTRY_BRAZIL ('BR')
|
||||
#define LOBBYAPI_COUNTRY_BRITISH_INDIAN_OCEAN_TERRITORY ('IO')
|
||||
#define LOBBYAPI_COUNTRY_BRUNEI_DARUSSALAM ('BN')
|
||||
#define LOBBYAPI_COUNTRY_BULGARIA ('BG')
|
||||
#define LOBBYAPI_COUNTRY_BURKINA_FASO ('BF')
|
||||
#define LOBBYAPI_COUNTRY_BURUNDI ('BI')
|
||||
#define LOBBYAPI_COUNTRY_CAMBODIA ('KH')
|
||||
#define LOBBYAPI_COUNTRY_CAMEROON ('CM')
|
||||
#define LOBBYAPI_COUNTRY_CANADA ('CA')
|
||||
#define LOBBYAPI_COUNTRY_CAPE_VERDE ('CV')
|
||||
#define LOBBYAPI_COUNTRY_CAYMAN_ISLANDS ('KY')
|
||||
#define LOBBYAPI_COUNTRY_CENTRAL_AFRICAN_REPUBLIC ('CF')
|
||||
#define LOBBYAPI_COUNTRY_CHAD ('TD')
|
||||
#define LOBBYAPI_COUNTRY_CHILE ('CL')
|
||||
#define LOBBYAPI_COUNTRY_CHINA ('CN')
|
||||
#define LOBBYAPI_COUNTRY_CHRISTMAS_ISLAND ('CX')
|
||||
#define LOBBYAPI_COUNTRY_COCOS_KEELING_ISLANDS ('CC')
|
||||
#define LOBBYAPI_COUNTRY_COLOMBIA ('CO')
|
||||
#define LOBBYAPI_COUNTRY_COMOROS ('KM')
|
||||
#define LOBBYAPI_COUNTRY_CONGO ('CG')
|
||||
#define LOBBYAPI_COUNTRY_COOK_ISLANDS ('CK')
|
||||
#define LOBBYAPI_COUNTRY_COSTA_RICA ('CR')
|
||||
#define LOBBYAPI_COUNTRY_COTE_DIVOIRE ('CI')
|
||||
#define LOBBYAPI_COUNTRY_CROATIA ('HR')
|
||||
#define LOBBYAPI_COUNTRY_CUBA ('CU')
|
||||
#define LOBBYAPI_COUNTRY_CYPRUS ('CY')
|
||||
#define LOBBYAPI_COUNTRY_CZECH_REPUBLIC ('CZ')
|
||||
#define LOBBYAPI_COUNTRY_DENMARK ('DK')
|
||||
#define LOBBYAPI_COUNTRY_DJIBOUTI ('DJ')
|
||||
#define LOBBYAPI_COUNTRY_DOMINICA ('DM')
|
||||
#define LOBBYAPI_COUNTRY_DOMINICAN_REPUBLIC ('DO')
|
||||
#define LOBBYAPI_COUNTRY_EAST_TIMOR ('TP')
|
||||
#define LOBBYAPI_COUNTRY_ECUADOR ('EC')
|
||||
#define LOBBYAPI_COUNTRY_EGYPT ('EG')
|
||||
#define LOBBYAPI_COUNTRY_EL_SALVADOR ('SV')
|
||||
#define LOBBYAPI_COUNTRY_EQUATORIAL_GUINEA ('GQ')
|
||||
#define LOBBYAPI_COUNTRY_ERITREA ('ER')
|
||||
#define LOBBYAPI_COUNTRY_ESTONIA ('EE')
|
||||
#define LOBBYAPI_COUNTRY_ETHIOPIA ('ET')
|
||||
#define LOBBYAPI_COUNTRY_EUROPE_SSGFI_ONLY ('EU')
|
||||
#define LOBBYAPI_COUNTRY_FALKLAND_ISLANDS ('FK')
|
||||
#define LOBBYAPI_COUNTRY_FAEROE_ISLANDS ('FO')
|
||||
#define LOBBYAPI_COUNTRY_FIJI ('FJ')
|
||||
#define LOBBYAPI_COUNTRY_FINLAND ('FI')
|
||||
#define LOBBYAPI_COUNTRY_FRANCE ('FR')
|
||||
#define LOBBYAPI_COUNTRY_FRANCE_METROPOLITAN ('FX')
|
||||
#define LOBBYAPI_COUNTRY_FRENCH_GUIANA ('GF')
|
||||
#define LOBBYAPI_COUNTRY_FRENCH_POLYNESIA ('PF')
|
||||
#define LOBBYAPI_COUNTRY_FRENCH_SOUTHERN_TERRITORIES ('TF')
|
||||
#define LOBBYAPI_COUNTRY_GABON ('GA')
|
||||
#define LOBBYAPI_COUNTRY_GAMBIA ('GM')
|
||||
#define LOBBYAPI_COUNTRY_GEORGIA ('GE')
|
||||
#define LOBBYAPI_COUNTRY_GERMANY ('DE')
|
||||
#define LOBBYAPI_COUNTRY_GHANA ('GH')
|
||||
#define LOBBYAPI_COUNTRY_GIBRALTAR ('GI')
|
||||
#define LOBBYAPI_COUNTRY_GREECE ('GR')
|
||||
#define LOBBYAPI_COUNTRY_GREENLAND ('GL')
|
||||
#define LOBBYAPI_COUNTRY_GRENADA ('GD')
|
||||
#define LOBBYAPI_COUNTRY_GUADELOUPE ('GP')
|
||||
#define LOBBYAPI_COUNTRY_GUAM ('GU')
|
||||
#define LOBBYAPI_COUNTRY_GUATEMALA ('GT')
|
||||
#define LOBBYAPI_COUNTRY_GUINEA ('GN')
|
||||
#define LOBBYAPI_COUNTRY_GUINEA_BISSAU ('GW')
|
||||
#define LOBBYAPI_COUNTRY_GUYANA ('GY')
|
||||
#define LOBBYAPI_COUNTRY_HAITI ('HT')
|
||||
#define LOBBYAPI_COUNTRY_HEARD_AND_MC_DONALD_ISLANDS ('HM')
|
||||
#define LOBBYAPI_COUNTRY_HONDURAS ('HN')
|
||||
#define LOBBYAPI_COUNTRY_HONG_KONG ('HK')
|
||||
#define LOBBYAPI_COUNTRY_HUNGARY ('HU')
|
||||
#define LOBBYAPI_COUNTRY_ICELAND ('IS')
|
||||
#define LOBBYAPI_COUNTRY_INDIA ('IN')
|
||||
#define LOBBYAPI_COUNTRY_INDONESIA ('ID')
|
||||
#define LOBBYAPI_COUNTRY_INTERNATIONAL_SSGFI_ONLY ('II')
|
||||
#define LOBBYAPI_COUNTRY_IRAN ('IR')
|
||||
#define LOBBYAPI_COUNTRY_IRAQ ('IQ')
|
||||
#define LOBBYAPI_COUNTRY_IRELAND ('IE')
|
||||
#define LOBBYAPI_COUNTRY_ISRAEL ('IL')
|
||||
#define LOBBYAPI_COUNTRY_ITALY ('IT')
|
||||
#define LOBBYAPI_COUNTRY_JAMAICA ('JM')
|
||||
#define LOBBYAPI_COUNTRY_JAPAN ('JP')
|
||||
#define LOBBYAPI_COUNTRY_JORDAN ('JO')
|
||||
#define LOBBYAPI_COUNTRY_KAZAKHSTAN ('KZ')
|
||||
#define LOBBYAPI_COUNTRY_KENYA ('KE')
|
||||
#define LOBBYAPI_COUNTRY_KIRIBATI ('KI')
|
||||
#define LOBBYAPI_COUNTRY_KOREA_DEMOCRATIC_PEOPLES_REPUBLIC_OF ('KP')
|
||||
#define LOBBYAPI_COUNTRY_KOREA_REPUBLIC_OF ('KR')
|
||||
#define LOBBYAPI_COUNTRY_KUWAIT ('KW')
|
||||
#define LOBBYAPI_COUNTRY_KYRGYZSTAN ('KG')
|
||||
#define LOBBYAPI_COUNTRY_LAO_PEOPLES_DEMOCRATIC_REPUBLIC ('LA')
|
||||
#define LOBBYAPI_COUNTRY_LATVIA ('LV')
|
||||
#define LOBBYAPI_COUNTRY_LEBANON ('LB')
|
||||
#define LOBBYAPI_COUNTRY_LESOTHO ('LS')
|
||||
#define LOBBYAPI_COUNTRY_LIBERIA ('LR')
|
||||
#define LOBBYAPI_COUNTRY_LIBYAN_ARAB_JAMAHIRIYA ('LY')
|
||||
#define LOBBYAPI_COUNTRY_LIECHTENSTEIN ('LI')
|
||||
#define LOBBYAPI_COUNTRY_LITHUANIA ('LT')
|
||||
#define LOBBYAPI_COUNTRY_LUXEMBOURG ('LU')
|
||||
#define LOBBYAPI_COUNTRY_MACAU ('MO')
|
||||
#define LOBBYAPI_COUNTRY_MACEDONIA_THE_FORMER_YUGOSLAV_REPUBLIC_OF ('MK')
|
||||
#define LOBBYAPI_COUNTRY_MADAGASCAR ('MG')
|
||||
#define LOBBYAPI_COUNTRY_MALAWI ('MW')
|
||||
#define LOBBYAPI_COUNTRY_MALAYSIA ('MY')
|
||||
#define LOBBYAPI_COUNTRY_MALDIVES ('MV')
|
||||
#define LOBBYAPI_COUNTRY_MALI ('ML')
|
||||
#define LOBBYAPI_COUNTRY_MALTA ('MT')
|
||||
#define LOBBYAPI_COUNTRY_MARSHALL_ISLANDS ('MH')
|
||||
#define LOBBYAPI_COUNTRY_MARTINIQUE ('MQ')
|
||||
#define LOBBYAPI_COUNTRY_MAURITANIA ('MR')
|
||||
#define LOBBYAPI_COUNTRY_MAURITIUS ('MU')
|
||||
#define LOBBYAPI_COUNTRY_MAYOTTE ('YT')
|
||||
#define LOBBYAPI_COUNTRY_MEXICO ('MX')
|
||||
#define LOBBYAPI_COUNTRY_MICRONESIA_FEDERATED_STATES_OF ('FM')
|
||||
#define LOBBYAPI_COUNTRY_MOLDOVA_REPUBLIC_OF ('MD')
|
||||
#define LOBBYAPI_COUNTRY_MONACO ('MC')
|
||||
#define LOBBYAPI_COUNTRY_MONGOLIA ('MN')
|
||||
#define LOBBYAPI_COUNTRY_MONTSERRAT ('MS')
|
||||
#define LOBBYAPI_COUNTRY_MOROCCO ('MA')
|
||||
#define LOBBYAPI_COUNTRY_MOZAMBIQUE ('MZ')
|
||||
#define LOBBYAPI_COUNTRY_MYANMAR ('MM')
|
||||
#define LOBBYAPI_COUNTRY_NAMIBIA ('NA')
|
||||
#define LOBBYAPI_COUNTRY_NAURU ('NR')
|
||||
#define LOBBYAPI_COUNTRY_NEPAL ('NP')
|
||||
#define LOBBYAPI_COUNTRY_NETHERLANDS ('NL')
|
||||
#define LOBBYAPI_COUNTRY_NETHERLANDS_ANTILLES ('AN')
|
||||
#define LOBBYAPI_COUNTRY_NEW_CALEDONIA ('NC')
|
||||
#define LOBBYAPI_COUNTRY_NEW_ZEALAND ('NZ')
|
||||
#define LOBBYAPI_COUNTRY_NICARAGUA ('NI')
|
||||
#define LOBBYAPI_COUNTRY_NIGER ('NE')
|
||||
#define LOBBYAPI_COUNTRY_NIGERIA ('NG')
|
||||
#define LOBBYAPI_COUNTRY_NIUE ('NU')
|
||||
#define LOBBYAPI_COUNTRY_NORFOLK_ISLAND ('NF')
|
||||
#define LOBBYAPI_COUNTRY_NORTHERN_MARIANA_ISLANDS ('MP')
|
||||
#define LOBBYAPI_COUNTRY_NORWAY ('NO')
|
||||
#define LOBBYAPI_COUNTRY_OMAN ('OM')
|
||||
#define LOBBYAPI_COUNTRY_PAKISTAN ('PK')
|
||||
#define LOBBYAPI_COUNTRY_PALAU ('PW')
|
||||
#define LOBBYAPI_COUNTRY_PANAMA ('PA')
|
||||
#define LOBBYAPI_COUNTRY_PAPUA_NEW_GUINEA ('PG')
|
||||
#define LOBBYAPI_COUNTRY_PARAGUAY ('PY')
|
||||
#define LOBBYAPI_COUNTRY_PERU ('PE')
|
||||
#define LOBBYAPI_COUNTRY_PHILIPPINES ('PH')
|
||||
#define LOBBYAPI_COUNTRY_PITCAIRN ('PN')
|
||||
#define LOBBYAPI_COUNTRY_POLAND ('PL')
|
||||
#define LOBBYAPI_COUNTRY_PORTUGAL ('PT')
|
||||
#define LOBBYAPI_COUNTRY_PUERTO_RICO ('PR')
|
||||
#define LOBBYAPI_COUNTRY_QATAR ('QA')
|
||||
#define LOBBYAPI_COUNTRY_REUNION ('RE')
|
||||
#define LOBBYAPI_COUNTRY_ROMANIA ('RO')
|
||||
#define LOBBYAPI_COUNTRY_RUSSIAN_FEDERATION ('RU')
|
||||
#define LOBBYAPI_COUNTRY_RWANDA ('RW')
|
||||
#define LOBBYAPI_COUNTRY_SAINT_KITTS_AND_NEVIS ('KN')
|
||||
#define LOBBYAPI_COUNTRY_SAINT_LUCIA ('LC')
|
||||
#define LOBBYAPI_COUNTRY_SAINT_VINCENT_AND_THE_GRENADINES ('VC')
|
||||
#define LOBBYAPI_COUNTRY_SAMOA ('WS')
|
||||
#define LOBBYAPI_COUNTRY_SAN_MARINO ('SM')
|
||||
#define LOBBYAPI_COUNTRY_SAO_TOME_AND_PRINCIPE ('ST')
|
||||
#define LOBBYAPI_COUNTRY_SAUDI_ARABIA ('SA')
|
||||
#define LOBBYAPI_COUNTRY_SENEGAL ('SN')
|
||||
#define LOBBYAPI_COUNTRY_SEYCHELLES ('SC')
|
||||
#define LOBBYAPI_COUNTRY_SIERRA_LEONE ('SL')
|
||||
#define LOBBYAPI_COUNTRY_SINGAPORE ('SG')
|
||||
#define LOBBYAPI_COUNTRY_SLOVAKIA ('SK')
|
||||
#define LOBBYAPI_COUNTRY_SLOVENIA ('SI')
|
||||
#define LOBBYAPI_COUNTRY_SOLOMON_ISLANDS ('SB')
|
||||
#define LOBBYAPI_COUNTRY_SOMALIA ('SO')
|
||||
#define LOBBYAPI_COUNTRY_SOUTH_AFRICA ('ZA')
|
||||
#define LOBBYAPI_COUNTRY_SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS ('GS')
|
||||
#define LOBBYAPI_COUNTRY_SPAIN ('ES')
|
||||
#define LOBBYAPI_COUNTRY_SRI_LANKA ('LK')
|
||||
#define LOBBYAPI_COUNTRY_ST_HELENA_ASCENSION_AND_TRISTAN_DA_CUNHA ('SH')
|
||||
#define LOBBYAPI_COUNTRY_ST_PIERRE_AND_MIQUELON ('PM')
|
||||
#define LOBBYAPI_COUNTRY_SUDAN ('SD')
|
||||
#define LOBBYAPI_COUNTRY_SURINAME ('SR')
|
||||
#define LOBBYAPI_COUNTRY_SVALBARD_AND_JAN_MAYEN_ISLANDS ('SJ')
|
||||
#define LOBBYAPI_COUNTRY_SWAZILAND ('SZ')
|
||||
#define LOBBYAPI_COUNTRY_SWEDEN ('SE')
|
||||
#define LOBBYAPI_COUNTRY_SWITZERLAND ('CH')
|
||||
#define LOBBYAPI_COUNTRY_SYRIAN_ARAB_REPUBLIC ('SY')
|
||||
#define LOBBYAPI_COUNTRY_TAIWAN ('TW')
|
||||
#define LOBBYAPI_COUNTRY_TAJIKISTAN ('TJ')
|
||||
#define LOBBYAPI_COUNTRY_TANZANIA_UNITED_REPUBLIC_OF ('TZ')
|
||||
#define LOBBYAPI_COUNTRY_THAILAND ('TH')
|
||||
#define LOBBYAPI_COUNTRY_TOGO ('TG')
|
||||
#define LOBBYAPI_COUNTRY_TOKELAU ('TK')
|
||||
#define LOBBYAPI_COUNTRY_TONGA ('TO')
|
||||
#define LOBBYAPI_COUNTRY_TRINIDAD_AND_TOBAGO ('TT')
|
||||
#define LOBBYAPI_COUNTRY_TUNISIA ('TN')
|
||||
#define LOBBYAPI_COUNTRY_TURKEY ('TR')
|
||||
#define LOBBYAPI_COUNTRY_TURKMENISTAN ('TM')
|
||||
#define LOBBYAPI_COUNTRY_TURKS_AND_CAICOS_ISLANDS ('TC')
|
||||
#define LOBBYAPI_COUNTRY_TUVALU ('TV')
|
||||
#define LOBBYAPI_COUNTRY_UGANDA ('UG')
|
||||
#define LOBBYAPI_COUNTRY_UKRAINE ('UA')
|
||||
#define LOBBYAPI_COUNTRY_UNITED_ARAB_EMIRATES ('AE')
|
||||
#define LOBBYAPI_COUNTRY_UNITED_KINGDOM ('GB')
|
||||
#define LOBBYAPI_COUNTRY_UNITED_STATES ('US')
|
||||
#define LOBBYAPI_COUNTRY_UNITED_STATES_MINOR_OUTLYING_ISLANDS ('UM')
|
||||
#define LOBBYAPI_COUNTRY_URUGUAY ('UY')
|
||||
#define LOBBYAPI_COUNTRY_UZBEKISTAN ('UZ')
|
||||
#define LOBBYAPI_COUNTRY_VANUATU ('VU')
|
||||
#define LOBBYAPI_COUNTRY_VATICAN_CITY_STATE ('VA')
|
||||
#define LOBBYAPI_COUNTRY_VENEZUELA ('VE')
|
||||
#define LOBBYAPI_COUNTRY_VIETNAM ('VN')
|
||||
#define LOBBYAPI_COUNTRY_VIRGIN_ISLANDS_BRITISH ('VG')
|
||||
#define LOBBYAPI_COUNTRY_VIRGIN_ISLANDS_US ('VI')
|
||||
#define LOBBYAPI_COUNTRY_WALLIS_AND_FUTUNA_ISLANDS ('WF')
|
||||
#define LOBBYAPI_COUNTRY_WESTERN_SAHARA ('EH')
|
||||
#define LOBBYAPI_COUNTRY_YEMEN ('YE')
|
||||
#define LOBBYAPI_COUNTRY_YUGOSLAVIA ('YU')
|
||||
#define LOBBYAPI_COUNTRY_ZAIRE ('ZR')
|
||||
#define LOBBYAPI_COUNTRY_ZAMBIA ('ZM')
|
||||
#define LOBBYAPI_COUNTRY_ZIMBABWE ('ZW')
|
||||
|
||||
// Countries: added on Mar-25-2011
|
||||
#define LOBBYAPI_COUNTRY_SERBIA_AND_MONTENEGRO ('CS')
|
||||
#define LOBBYAPI_COUNTRY_MONTENEGRO ('ME')
|
||||
#define LOBBYAPI_COUNTRY_SERBIA ('RS')
|
||||
#define LOBBYAPI_COUNTRY_CONGO_DRC ('CD')
|
||||
#define LOBBYAPI_COUNTRY_PALESTINIAN_TERRITORY ('PS')
|
||||
#define LOBBYAPI_COUNTRY_GUERNSEY ('GG')
|
||||
#define LOBBYAPI_COUNTRY_JERSEY ('JE')
|
||||
#define LOBBYAPI_COUNTRY_ISLE_OF_MAN ('IM')
|
||||
#define LOBBYAPI_COUNTRY_TIMOR_LESTE ('TL')
|
||||
|
||||
// Default country
|
||||
#define LOBBYAPI_COUNTRY_DEFAULT LOBBYAPI_COUNTRY_UNITED_STATES
|
||||
#define LOBBYAPI_COUNTRY_DEFAULT_STR "US"
|
||||
|
||||
|
||||
//! Currencies (ISO-4217)
|
||||
#define LOBBYAPI_CURRENCY_UNITED_ARAB_EMIRATS_DIRHAM ('AED')
|
||||
#define LOBBYAPI_CURRENCY_AFGHAN_AFGHANI ('AFN')
|
||||
#define LOBBYAPI_CURRENCY_ALBANIAN_LEK ('ALL')
|
||||
#define LOBBYAPI_CURRENCY_ARMENIAN_DRAM ('AMD')
|
||||
#define LOBBYAPI_CURRENCY_NETHERLANDS_ANTILLEAN_GUILDER ('ANG')
|
||||
#define LOBBYAPI_CURRENCY_ANGOLAN_KWANZA ('AOA')
|
||||
#define LOBBYAPI_CURRENCY_ARGENTINE_PESO ('ARS')
|
||||
#define LOBBYAPI_CURRENCY_AUSTRALIAN_DOLLAR ('AUD')
|
||||
#define LOBBYAPI_CURRENCY_ARUBAN_FLORIN ('AWG')
|
||||
#define LOBBYAPI_CURRENCY_AZERBAIJANI_PMANAT ('AZN')
|
||||
#define LOBBYAPI_CURRENCY_BOSNIA_AND_HERZEGOVINA_CONVERTIBLE_MARK ('BAM')
|
||||
#define LOBBYAPI_CURRENCY_BARBADOS_DOLLAR ('BBD')
|
||||
#define LOBBYAPI_CURRENCY_BANGLADESHI_TAKA ('BDT')
|
||||
#define LOBBYAPI_CURRENCY_BULGARIAN_LEV ('BGN')
|
||||
#define LOBBYAPI_CURRENCY_BAHRAINI_DINAR ('BHD')
|
||||
#define LOBBYAPI_CURRENCY_BURUNDIAN_FRANC ('BIF')
|
||||
#define LOBBYAPI_CURRENCY_BERMUDIAN_DOLLAR ('BMD')
|
||||
#define LOBBYAPI_CURRENCY_BRUNEI_DOLLAR ('BND')
|
||||
#define LOBBYAPI_CURRENCY_BOLIVIANO ('BOB')
|
||||
#define LOBBYAPI_CURRENCY_BOLIVIAN_MVDOL ('BOV')
|
||||
#define LOBBYAPI_CURRENCY_BRAZILIAN_REAL ('BRL')
|
||||
#define LOBBYAPI_CURRENCY_BAHAMIAN_DOLLAR ('BSD')
|
||||
#define LOBBYAPI_CURRENCY_BHUTANESE_NGULTRUM ('BTN')
|
||||
#define LOBBYAPI_CURRENCY_BOTSWANA_PULA ('BWP')
|
||||
#define LOBBYAPI_CURRENCY_BELARUSIAN_RUBLE ('BYR')
|
||||
#define LOBBYAPI_CURRENCY_BELIZE_DOLLAR ('BZD')
|
||||
#define LOBBYAPI_CURRENCY_CANADIAN_DOLLAR ('CAD')
|
||||
#define LOBBYAPI_CURRENCY_CONGOLESE_FRANC ('CDF')
|
||||
#define LOBBYAPI_CURRENCY_WIR_EURO ('CHE')
|
||||
#define LOBBYAPI_CURRENCY_SWISS_FRANC ('CHF')
|
||||
#define LOBBYAPI_CURRENCY_WIR_FRANC ('CHW')
|
||||
#define LOBBYAPI_CURRENCY_UNIDAD_DE_FOMENTO ('CLF')
|
||||
#define LOBBYAPI_CURRENCY_CHILEAN_PESO ('CLP')
|
||||
#define LOBBYAPI_CURRENCY_CHINESE_YUAN ('CNY')
|
||||
#define LOBBYAPI_CURRENCY_COLOBIAN_PESO ('COP')
|
||||
#define LOBBYAPI_CURRENCY_UNIDAD_DE_VALOR_REAL ('COU')
|
||||
#define LOBBYAPI_CURRENCY_COSTA_RICAN_COLON ('CRC')
|
||||
#define LOBBYAPI_CURRENCY_CUBAN_CONVERTIBLE_PESO ('CUC')
|
||||
#define LOBBYAPI_CURRENCY_CUBAN_PESO ('CUP')
|
||||
#define LOBBYAPI_CURRENCY_CAP_VERDE_ESCUDO ('CVE')
|
||||
#define LOBBYAPI_CURRENCY_CZECH_KORUNA ('CZK')
|
||||
#define LOBBYAPI_CURRENCY_DJIBOUTIAN_FRANC ('DJF')
|
||||
#define LOBBYAPI_CURRENCY_DANISH_KRONE ('DKK')
|
||||
#define LOBBYAPI_CURRENCY_DOMINICAN_PESO ('DOP')
|
||||
#define LOBBYAPI_CURRENCY_ALGERIAN_DINAR ('DZD')
|
||||
#define LOBBYAPI_CURRENCY_EGYPTIAN_POUND ('EGP')
|
||||
#define LOBBYAPI_CURRENCY_ERITREAN_NAKFA ('ERN')
|
||||
#define LOBBYAPI_CURRENCY_ETHIOPIAN_BIRR ('ETB')
|
||||
#define LOBBYAPI_CURRENCY_EURO ('EUR')
|
||||
#define LOBBYAPI_CURRENCY_FIJI_DOLLAR ('FJD')
|
||||
#define LOBBYAPI_CURRENCY_FALKLAND_ISLANDS_POUND ('FKP')
|
||||
#define LOBBYAPI_CURRENCY_POUND_STERLING ('GBP')
|
||||
#define LOBBYAPI_CURRENCY_GEORGIAN_LARI ('GEL')
|
||||
#define LOBBYAPI_CURRENCY_GHANAIAN_CEDI ('GHS')
|
||||
#define LOBBYAPI_CURRENCY_GIBRALTAR_POUND ('GIP')
|
||||
#define LOBBYAPI_CURRENCY_GAMBIAN_DALASI ('GMD')
|
||||
#define LOBBYAPI_CURRENCY_GUINEAN_FRANC ('GNF')
|
||||
#define LOBBYAPI_CURRENCY_GUATEMALAN_QUETZAL ('GTQ')
|
||||
#define LOBBYAPI_CURRENCY_GUYANESE_DOLLAR ('GYD')
|
||||
#define LOBBYAPI_CURRENCY_HONG_KONG_DOLLAR ('HKD')
|
||||
#define LOBBYAPI_CURRENCY_HONDURAN_LEMPIRA ('HNL')
|
||||
#define LOBBYAPI_CURRENCY_CROATIAN_KUNA ('HRK')
|
||||
#define LOBBYAPI_CURRENCY_HAITIAN_GOURDE ('HTG')
|
||||
#define LOBBYAPI_CURRENCY_HUNGARIAN_FORINT ('HUF')
|
||||
#define LOBBYAPI_CURRENCY_INDONESIAN_RUPIAH ('IDR')
|
||||
#define LOBBYAPI_CURRENCY_ISRAELI_NEW_SHEQEL ('ILS')
|
||||
#define LOBBYAPI_CURRENCY_INDIAN_RUPEE ('INR')
|
||||
#define LOBBYAPI_CURRENCY_IRAQI_DINAR ('IQD')
|
||||
#define LOBBYAPI_CURRENCY_IRANIAN_RIAL ('IRR')
|
||||
#define LOBBYAPI_CURRENCY_ICELANDIC_KRONA ('ISK')
|
||||
#define LOBBYAPI_CURRENCY_JAMAICAN_DOLLAR ('JMD')
|
||||
#define LOBBYAPI_CURRENCY_JORDANIAN_DINAR ('JOD')
|
||||
#define LOBBYAPI_CURRENCY_JAPANESE_YEN ('JPY')
|
||||
#define LOBBYAPI_CURRENCY_KENYAN_SHILLING ('KES')
|
||||
#define LOBBYAPI_CURRENCY_KYRGYZSTANI_SOM ('KGS')
|
||||
#define LOBBYAPI_CURRENCY_CAMBODIAN_RIEL ('KHR')
|
||||
#define LOBBYAPI_CURRENCY_COMORO_FRANC ('KMF')
|
||||
#define LOBBYAPI_CURRENCY_NORTH_KOREAN_WON ('KPW')
|
||||
#define LOBBYAPI_CURRENCY_SOUTH_KOREAN_WON ('KRW')
|
||||
#define LOBBYAPI_CURRENCY_KUWAITI_DINAR ('KWD')
|
||||
#define LOBBYAPI_CURRENCY_CAYMAN_ISLANDS_DOLLAR ('KYD')
|
||||
#define LOBBYAPI_CURRENCY_KAZAKHSTANI_TENGE ('KZT')
|
||||
#define LOBBYAPI_CURRENCY_LAO_KIP ('LAK')
|
||||
#define LOBBYAPI_CURRENCY_LEBANESE_POUND ('LBP')
|
||||
#define LOBBYAPI_CURRENCY_SRI_LANKAN_RUPEE ('LKR')
|
||||
#define LOBBYAPI_CURRENCY_LIBERIAN_DOLLAR ('LRD')
|
||||
#define LOBBYAPI_CURRENCY_LESOTHO_LOTI ('LSL')
|
||||
#define LOBBYAPI_CURRENCY_LITHUANIAN_LITAS ('LTL')
|
||||
#define LOBBYAPI_CURRENCY_LATVIAN_LATS ('LVL')
|
||||
#define LOBBYAPI_CURRENCY_LYBIAN_DINAR ('LYD')
|
||||
#define LOBBYAPI_CURRENCY_MOROCCAN_DIRHAM ('MAD')
|
||||
#define LOBBYAPI_CURRENCY_MOLDOVAN_LEU ('MDL')
|
||||
#define LOBBYAPI_CURRENCY_MALAGASY_ARIARY ('MGA')
|
||||
#define LOBBYAPI_CURRENCY_MACEDONIAN_DENAR ('MKD')
|
||||
#define LOBBYAPI_CURRENCY_MYANMA_KYAT ('MMK')
|
||||
#define LOBBYAPI_CURRENCY_MONGOLIAN_TUGRIK ('MNT')
|
||||
#define LOBBYAPI_CURRENCY_MACANESE_PATACA ('MOP')
|
||||
#define LOBBYAPI_CURRENCY_MAURITANIAN_OUGUIYA ('MRO')
|
||||
#define LOBBYAPI_CURRENCY_MAURITIAN_RUPEE ('MUR')
|
||||
#define LOBBYAPI_CURRENCY_MALDIVIAN_RUFIYAA ('MVR')
|
||||
#define LOBBYAPI_CURRENCY_MALAWAIAN_KWACHA ('MWK')
|
||||
#define LOBBYAPI_CURRENCY_MEXICAN_PESO ('MXN')
|
||||
#define LOBBYAPI_CURRENCY_MEXICAN_UNIDAD_DE_INVERSION ('MXV')
|
||||
#define LOBBYAPI_CURRENCY_MALAYSIAN_RINGGIT ('MYR')
|
||||
#define LOBBYAPI_CURRENCY_MOZAMBICAN_METICAL ('MZN')
|
||||
#define LOBBYAPI_CURRENCY_NAMIBIAN_DOLLAR ('NAD')
|
||||
#define LOBBYAPI_CURRENCY_NIGERIAN_NAIRA ('NGN')
|
||||
#define LOBBYAPI_CURRENCY_NICARAGUAN_CORDOBA ('NIO')
|
||||
#define LOBBYAPI_CURRENCY_NORVEGIAN_KRONE ('NOK')
|
||||
#define LOBBYAPI_CURRENCY_NEPALESE_RUPEE ('NPR')
|
||||
#define LOBBYAPI_CURRENCY_NEW_ZEALAND_DOLLAR ('NZD')
|
||||
#define LOBBYAPI_CURRENCY_OMANI_RIAL ('OMR')
|
||||
#define LOBBYAPI_CURRENCY_PANAMANIAN_BALBOA ('PAB')
|
||||
#define LOBBYAPI_CURRENCY_PERUVIAN_NUEVO_SOL ('PEN')
|
||||
#define LOBBYAPI_CURRENCY_PAPUA_NEW_GUINEAN_KINA ('PGK')
|
||||
#define LOBBYAPI_CURRENCY_PHILIPPINE_PESO ('PHP')
|
||||
#define LOBBYAPI_CURRENCY_PAKISTANI_RUPEE ('PKR')
|
||||
#define LOBBYAPI_CURRENCY_POLISH_ZLOTY ('PLN')
|
||||
#define LOBBYAPI_CURRENCY_PARAGUAYAN_GUARANI ('PYG')
|
||||
#define LOBBYAPI_CURRENCY_QATARI_RIAL ('QAR')
|
||||
#define LOBBYAPI_CURRENCY_ROMANIAN_NEW_LEU ('RON')
|
||||
#define LOBBYAPI_CURRENCY_SERBIAN_DINAR ('RSD')
|
||||
#define LOBBYAPI_CURRENCY_RUSSIAN_RUBLE ('RUB')
|
||||
#define LOBBYAPI_CURRENCY_RWANDAN_FRANC ('RWF')
|
||||
#define LOBBYAPI_CURRENCY_SAUDI_RIYAL ('SAR')
|
||||
#define LOBBYAPI_CURRENCY_SOLOMON_ISLANDS_DOLLAR ('SBD')
|
||||
#define LOBBYAPI_CURRENCY_SEYCHELLES_RUPEE ('SRC')
|
||||
#define LOBBYAPI_CURRENCY_SUDANESE_POUND ('SDG')
|
||||
#define LOBBYAPI_CURRENCY_SWEDISH_KRONA ('SEK')
|
||||
#define LOBBYAPI_CURRENCY_SINGAPORE_DOLLAR ('SGD')
|
||||
#define LOBBYAPI_CURRENCY_SAINT_HELENA_POUND ('SHP')
|
||||
#define LOBBYAPI_CURRENCY_SIERRA_LEONEAN_LEONE ('SLL')
|
||||
#define LOBBYAPI_CURRENCY_SOMALI_SHILLING ('SOS')
|
||||
#define LOBBYAPI_CURRENCY_SURINAMESE_DOLLAR ('SRD')
|
||||
#define LOBBYAPI_CURRENCY_SOUTH_SUDANESE_POUND ('SSP')
|
||||
#define LOBBYAPI_CURRENCY_SAO_TOME_AND_PRINCIPE_DOBRA ('STD')
|
||||
#define LOBBYAPI_CURRENCY_SYRIAN_POUND ('SYP')
|
||||
#define LOBBYAPI_CURRENCY_SWAZI_LILANGENI ('SZL')
|
||||
#define LOBBYAPI_CURRENCY_THAI_BAHT ('THB')
|
||||
#define LOBBYAPI_CURRENCY_TAJIKISTANI_SOMONI ('TJS')
|
||||
#define LOBBYAPI_CURRENCY_TURKMENISTANI_MANAT ('TMT')
|
||||
#define LOBBYAPI_CURRENCY_TUNISIAN_DINAR ('TND')
|
||||
#define LOBBYAPI_CURRENCY_TONGAN_PAANGA ('TOP')
|
||||
#define LOBBYAPI_CURRENCY_TURKISH_LIRA ('TRY')
|
||||
#define LOBBYAPI_CURRENCY_TRINIDAD_AND_TOBAGO_DOLLAR ('TTD')
|
||||
#define LOBBYAPI_CURRENCY_NEW_TAIWAN_DOLLAR ('TWD')
|
||||
#define LOBBYAPI_CURRENCY_TANZANIAN_SHILLING ('TZS')
|
||||
#define LOBBYAPI_CURRENCY_UKRAINIAN_HRYVNIA ('UAH')
|
||||
#define LOBBYAPI_CURRENCY_UGANDAN_SHILLING ('UGX')
|
||||
#define LOBBYAPI_CURRENCY_UNITED_STATES_DOLLAR ('USD')
|
||||
#define LOBBYAPI_CURRENCY_UNITED_STATES_DOLLAR_NEXT_DAY ('USN')
|
||||
#define LOBBYAPI_CURRENCY_UNITED_STATES_DOLLAR_SAME_DAY ('USS')
|
||||
#define LOBBYAPI_CURRENCY_URUGUAY_PESO_EN_UNIDADES_INDEXADAS ('UYI')
|
||||
#define LOBBYAPI_CURRENCY_URUGUAYAN_PESO ('UYU')
|
||||
#define LOBBYAPI_CURRENCY_UZBEKISTAN_SOM ('UZS')
|
||||
#define LOBBYAPI_CURRENCY_VENEZUELAN_BOLIVAR_FUERTE ('VEF')
|
||||
#define LOBBYAPI_CURRENCY_VIETNAMESE_DONG ('VND')
|
||||
#define LOBBYAPI_CURRENCY_VANUATU_VATU ('VUV')
|
||||
#define LOBBYAPI_CURRENCY_SAMOAN_TALA ('WST')
|
||||
#define LOBBYAPI_CURRENCY_CFA_FRANC_BEAC ('XAF')
|
||||
#define LOBBYAPI_CURRENCY_EAST_CARABBEAN_DOLLAR ('XCD')
|
||||
#define LOBBYAPI_CURRENCY_CFA_FRANC_BCEAO ('XOF')
|
||||
#define LOBBYAPI_CURRENCY_CFP_FRANC ('XPF')
|
||||
#define LOBBYAPI_CURRENCY_YEMENI_RIAL ('YER')
|
||||
#define LOBBYAPI_CURRENCY_SOUTH_AFRICAN_RAND ('ZAR')
|
||||
#define LOBBYAPI_CURRENCY_ZAMBIAN_KWACHA ('ZMK')
|
||||
#define LOBBYAPI_CURRENCY_ZIMBABWE_DOLLAR ('ZWL')
|
||||
|
||||
// Default currency
|
||||
#define LOBBYAPI_CURRENCY_DEFAULT LOBBYAPI_CURRENCY_UNITED_STATES_DOLLAR
|
||||
#define LOBBYAPI_CURRENCY_DEFAULT_STR "USD"
|
||||
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
//! Write the currency code to a character string
|
||||
#define LOBBYAPI_CreateCurrencyString(strOutstring, uCurrency) \
|
||||
{ \
|
||||
(strOutstring)[0] = (char)(((uCurrency) >> 16 ) & 0xFF); \
|
||||
(strOutstring)[1] = (char)(((uCurrency) >> 8) & 0xFF); \
|
||||
(strOutstring)[2] = (char)((uCurrency) & 0xFF); \
|
||||
(strOutstring)[3]='\0'; \
|
||||
}
|
||||
|
||||
//! toupper replacement
|
||||
#define LOBBYAPI_LocalizerTokenToUpper(uCharToModify) \
|
||||
((((unsigned char)(uCharToModify) >= 'a') && ((unsigned char)(uCharToModify) <= 'z')) ? \
|
||||
(((unsigned char)(uCharToModify)) & (~32)) : \
|
||||
(uCharToModify))
|
||||
|
||||
//! tolower replacement
|
||||
#define LOBBYAPI_LocalizerTokenToLower(uCharToModify) \
|
||||
((((unsigned char)(uCharToModify) >= 'A') && ((unsigned char)(uCharToModify) <= 'Z')) ? \
|
||||
(((unsigned char)(uCharToModify)) | (32)) : \
|
||||
(uCharToModify))
|
||||
|
||||
//! Create a localizer token from shorts representing country and language
|
||||
#define LOBBYAPI_LocalizerTokenCreate(uLanguage, uCountry) \
|
||||
(((LOBBYAPI_LocalizerTokenShortToLower(uLanguage)) << 16) + (LOBBYAPI_LocalizerTokenShortToUpper(uCountry)))
|
||||
|
||||
//! Create a localizer token from strings containing country and language
|
||||
#define LOBBYAPI_LocalizerTokenCreateFromStrings(strLanguage, strCountry) \
|
||||
(LOBBYAPI_LocalizerTokenCreate(LOBBYAPI_LocalizerTokenGetShortFromString(strLanguage),LOBBYAPI_LocalizerTokenGetShortFromString(strCountry)))
|
||||
|
||||
//! Create a localizer token from a single string (language + country - ex: "enUS")
|
||||
#define LOBBYAPI_LocalizerTokenCreateFromString(strLocality) \
|
||||
(LOBBYAPI_LocalizerTokenCreateFromStrings(&(strLocality)[0], &(strLocality)[2]))
|
||||
|
||||
//! Get a int16_t integer from a string
|
||||
#define LOBBYAPI_LocalizerTokenGetShortFromString(strInstring) (( (((unsigned char*)(strInstring) == NULL) || ((unsigned char*)strInstring)[0] == '\0')) ? \
|
||||
((uint16_t)(0)) : \
|
||||
((uint16_t)((((unsigned char*)strInstring)[0] << 8) | ((unsigned char*)strInstring)[1])))
|
||||
|
||||
//! Pull the country (int16_t) from a localizer token (int32_t)
|
||||
#define LOBBYAPI_LocalizerTokenGetCountry(uToken) ((uint16_t)((uToken) & 0xFFFF))
|
||||
|
||||
//! Pull the language (int16_t) from a localizer token (int32_t)
|
||||
#define LOBBYAPI_LocalizerTokenGetLanguage(uToken) ((uint16_t)(((uToken) >> 16) & 0xFFFF))
|
||||
|
||||
//! Replace the country in a locality value
|
||||
#define LOBBYAPI_LocalizerTokenSetCountry(uToken, uCountry) (uToken) = (((uToken) & 0xFFFF0000) | (uCountry));
|
||||
|
||||
//! Replace the language in a locality value
|
||||
#define LOBBYAPI_LocalizerTokenSetLanguage(uToken, uLanguage) (uToken) = (((uToken) & 0x0000FFFF) | ((uLanguage) << 16));
|
||||
|
||||
//! Write the country contained in a localizer token to a character string
|
||||
#define LOBBYAPI_LocalizerTokenCreateCountryString(strOutstring, uToken) \
|
||||
{ \
|
||||
(strOutstring)[0] = (char)(((uToken) >> 8) & 0xFF); \
|
||||
(strOutstring)[1] = (char)((uToken) & 0xFF); \
|
||||
(strOutstring)[2]='\0'; \
|
||||
}
|
||||
|
||||
|
||||
//! Write the language contained in a localizer token to a character string
|
||||
#define LOBBYAPI_LocalizerTokenCreateLanguageString(strOutstring, uToken) \
|
||||
{ \
|
||||
(strOutstring)[0]=(char)(((uToken) >> 24) & 0xFF); \
|
||||
(strOutstring)[1]=(char)(((uToken) >> 16) & 0xFF); \
|
||||
(strOutstring)[2]='\0'; \
|
||||
}
|
||||
|
||||
//! Write the entire locality string to a character string
|
||||
#define LOBBYAPI_LocalizerTokenCreateLocalityString(strOutstring, uToken) \
|
||||
{ \
|
||||
(strOutstring)[0]=(char)(((uToken) >> 24) & 0xFF); \
|
||||
(strOutstring)[1]=(char)(((uToken) >> 16) & 0xFF); \
|
||||
(strOutstring)[2]=(char)(((uToken) >> 8) & 0xFF); \
|
||||
(strOutstring)[3]=(char)((uToken) & 0xFF); \
|
||||
(strOutstring)[4]='\0'; \
|
||||
}
|
||||
|
||||
//! Macro to provide an easy way to display the token in character format
|
||||
#define LOBBYAPI_LocalizerTokenPrintCharArray(uToken) \
|
||||
(char)(((uToken)>>24)&0xFF), (char)(((uToken)>>16)&0xFF), (char)(((uToken)>>8)&0xFF), (char)((uToken)&0xFF)
|
||||
|
||||
//! Provide a way to capitalize the elements in a int16_t
|
||||
#define LOBBYAPI_LocalizerTokenShortToUpper(uShort) \
|
||||
((uint16_t)(((LOBBYAPI_LocalizerTokenToUpper(((uShort) >> 8) & 0xFF)) << 8) + \
|
||||
(LOBBYAPI_LocalizerTokenToUpper((uShort) & 0xFF))))
|
||||
|
||||
//! Provide a way to lowercase the elements in a int16_t
|
||||
#define LOBBYAPI_LocalizerTokenShortToLower(uShort) \
|
||||
((uint16_t)(((LOBBYAPI_LocalizerTokenToLower(((uShort) >> 8) & 0xFF)) << 8) + \
|
||||
(LOBBYAPI_LocalizerTokenToLower((uShort) & 0xFF))))
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtylang_h
|
||||
|
44
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock.h
vendored
Normal file
44
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File dirtysock.h
|
||||
|
||||
\Description
|
||||
Platform independent interface to network layers. Based on
|
||||
BSD sockets, but with performance modifications. Allows truly
|
||||
portable modules to be written and moved to different platforms
|
||||
needing only different support wrappers (no change to actual
|
||||
network modes).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2001-2014
|
||||
|
||||
\Version 1.0 08/01/2001 (gschaefer) First Version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtysock_h
|
||||
#define _dirtysock_h
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
#ifndef DIRTYSOCK
|
||||
#define DIRTYSOCK (TRUE)
|
||||
#include "DirtySDK/dirtydefs.h"
|
||||
#include "DirtySDK/dirtysock/dirtynet.h"
|
||||
#include "DirtySDK/dirtysock/dirtylib.h"
|
||||
#endif
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#endif // _dirtysock_h
|
||||
|
98
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyaddr.h
vendored
Normal file
98
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyaddr.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtyaddr.h
|
||||
|
||||
\Description
|
||||
Definition for portable address type.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2004
|
||||
|
||||
\Version 1.0 04/07/2004 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtyaddr_h
|
||||
#define _dirtyaddr_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyAddr DirtyAddr
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#if defined(DIRTYCODE_XBOXONE) && !defined(DIRTYCODE_GDK)
|
||||
/* In production, when an xboxone is located behind an OpenWRT based router that has
|
||||
an IPv6 connection, the router defaults to assigning ULA prefixes via SLAAC and
|
||||
DHCPv6. This results in the console having a global IPv6 address, a link local
|
||||
IPv6 address, 2 ULA IPv6 addresses, and an IPv4 address. In such a scenario,
|
||||
the Secure Device Address of the console is large enough that it cannot fit in a
|
||||
127-byte DirtyAddrT (size used on other platforms).
|
||||
|
||||
After checking with MS, we got a confirmation that the size of a
|
||||
SecureDevicAddress will never exceed 300 bytes. (enforced both in the
|
||||
Windows::Networking::XboxLive and the Windows::Xbox::Networking namespaces).
|
||||
|
||||
A call to DirtyAddrSetInfoXboxOne() for a 300-byte SecureDeviceAddress blob
|
||||
results in 370 bytes being written in the DirtyAddrT. Consequently, it is safe
|
||||
to make the size DIRTYADDR_MACHINEADDR_MAXLEN 372 on xboxone.
|
||||
*/
|
||||
#define DIRTYADDR_MACHINEADDR_MAXLEN (372)
|
||||
#else
|
||||
#define DIRTYADDR_MACHINEADDR_MAXLEN (127)
|
||||
#endif
|
||||
#define DIRTYADDR_MACHINEADDR_MAXSIZE (DIRTYADDR_MACHINEADDR_MAXLEN + 1)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
//! compare two opaque addresses for equality (same=TRUE, different=FALSE)
|
||||
#define DirtyAddrCompare(_pAddr1, _pAddr2) (!strcmp((_pAddr1)->strMachineAddr, (_pAddr2)->strMachineAddr))
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque address type
|
||||
typedef struct DirtyAddrT
|
||||
{
|
||||
char strMachineAddr[DIRTYADDR_MACHINEADDR_MAXSIZE];
|
||||
} DirtyAddrT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! convert a DirtyAddrT to native format
|
||||
DIRTYCODE_API uint32_t DirtyAddrToHostAddr(void *pOutput, int32_t iBufLen, const DirtyAddrT *pAddr);
|
||||
|
||||
//! convert a host-format address to native format
|
||||
DIRTYCODE_API uint32_t DirtyAddrFromHostAddr(DirtyAddrT *pAddr, const void *pInput);
|
||||
|
||||
//! get local address in DirtyAddr form
|
||||
DIRTYCODE_API uint32_t DirtyAddrGetLocalAddr(DirtyAddrT *pAddr);
|
||||
|
||||
#if defined(DIRTYCODE_XBOXONE) && !defined(DIRTYCODE_GDK)
|
||||
//! get Xbox One extended info into dirtyaddr
|
||||
DIRTYCODE_API uint8_t DirtyAddrGetInfoXboxOne(const DirtyAddrT *pDirtyAddr, void *pXuid, void *pSecureDeviceAddressBlob, int32_t *pBlobSize);
|
||||
|
||||
//! set Xbox One extended info into dirtyaddr
|
||||
DIRTYCODE_API void DirtyAddrSetInfoXboxOne(DirtyAddrT *pDirtyAddr, const void *pXuid, const void *pSecureDeviceAddressBlob, int32_t iBlobSize);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtyaddr_h
|
||||
|
77
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtycert.h
vendored
Normal file
77
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtycert.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtycert.h
|
||||
|
||||
\Description
|
||||
This module defines the CA fallback mechanism which is used by ProtoSSL.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2012 Electronic Arts Inc.
|
||||
|
||||
\Version 01/23/2012 (szhu)
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtycert_h
|
||||
#define _dirtycert_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetConnDefs NetConnDefs
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protossl.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
#define DIRTYCERT_SERVICENAME_SIZE (128)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
// opaque module state ref
|
||||
typedef struct DirtyCertRefT DirtyCertRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create dirtycert module
|
||||
DIRTYCODE_API int32_t DirtyCertCreate(void);
|
||||
|
||||
// release resources and destroy module
|
||||
DIRTYCODE_API int32_t DirtyCertDestroy(void);
|
||||
|
||||
// initiate a CA fetch request
|
||||
DIRTYCODE_API int32_t DirtyCertCARequestCert(const ProtoSSLCertInfoT *pCertInfo, const char *pHost, int32_t iPort);
|
||||
|
||||
// initiate a CA prefetch request
|
||||
DIRTYCODE_API void DirtyCertCAPreloadCerts(const char *pServiceName);
|
||||
|
||||
// if a CA fetch request is complete
|
||||
DIRTYCODE_API int32_t DirtyCertCARequestDone(int32_t iRequestId);
|
||||
|
||||
// release resources used by a CA fetch request
|
||||
DIRTYCODE_API int32_t DirtyCertCARequestFree(int32_t iRequestId);
|
||||
|
||||
// control module behavior
|
||||
DIRTYCODE_API int32_t DirtyCertControl(int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// get module status
|
||||
DIRTYCODE_API int32_t DirtyCertStatus(int32_t iStatus, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtycert_h
|
97
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyerr.h
vendored
Normal file
97
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyerr.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtyerr.h
|
||||
|
||||
\Description
|
||||
Dirtysock debug error routines.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts
|
||||
|
||||
\Version 06/13/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtyerr_h
|
||||
#define _dirtyerr_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyErr DirtyErr
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define DIRTYSOCK_ERRORNAMES (DIRTYCODE_LOGGING && TRUE)
|
||||
#define DIRTYSOCK_LISTTERM (0x45454545)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
#if DIRTYSOCK_ERRORNAMES
|
||||
#define DIRTYSOCK_ErrorName(_iError) { (uint32_t)_iError, #_iError }
|
||||
#define DIRTYSOCK_ListEnd() { DIRTYSOCK_LISTTERM, "" }
|
||||
#endif
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct DirtyErrT
|
||||
{
|
||||
uint32_t uError;
|
||||
const char *pErrorName;
|
||||
} DirtyErrT;
|
||||
|
||||
#ifdef DIRTYCODE_PS4
|
||||
|
||||
typedef void (*DirtySockAppErrorCallback)(int32_t errorCode);
|
||||
|
||||
#endif
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DIRTYCODE_PS4
|
||||
|
||||
//set Application Error Callback
|
||||
void DirtyErrAppCallbackSet(DirtySockAppErrorCallback pCallback);
|
||||
|
||||
//Inovke App Error Callback if set to report sony error code back to application layer
|
||||
void DirtyErrAppReport(int32_t iError);
|
||||
|
||||
#endif
|
||||
|
||||
// take a system-specific error code, and either resolve it to its define name or format it as a hex number
|
||||
DIRTYCODE_API void DirtyErrName(char *pBuffer, int32_t iBufSize, uint32_t uError);
|
||||
|
||||
// same as DirtyErrName, but references the specified list
|
||||
DIRTYCODE_API void DirtyErrNameList(char *pBuffer, int32_t iBufSize, uint32_t uError, const DirtyErrT *pList);
|
||||
|
||||
// same as DirtyErrName, except a pointer is returned
|
||||
DIRTYCODE_API const char *DirtyErrGetName(uint32_t uError);
|
||||
|
||||
// same as DirtyErrGetName, but references the specified list
|
||||
DIRTYCODE_API const char *DirtyErrGetNameList(uint32_t uError, const DirtyErrT *pList);
|
||||
|
||||
// create a unique error code for use accross DirtySDK
|
||||
DIRTYCODE_API uint32_t DirtyErrGetHResult(uint16_t uFacility, int16_t iCode, uint8_t bFailure);
|
||||
|
||||
// break a hresult back into its components
|
||||
DIRTYCODE_API void DirtyErrDecodeHResult(uint32_t hResult, uint16_t* uFacility, int16_t* iCode, uint8_t* bCustomer, uint8_t* bFailure);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtyerr_h
|
||||
|
234
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtylib.h
vendored
Normal file
234
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtylib.h
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
/*H**************************************************************************************/
|
||||
/*!
|
||||
\File dirtylib.h
|
||||
|
||||
\Description
|
||||
Provide basic library functions for use by network layer code.
|
||||
This is needed because the network code is platform/project
|
||||
independent and needs to rely on a certain set of basic
|
||||
functions.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2001-2018
|
||||
|
||||
\Version 0.5 08/01/01 (GWS) First Version
|
||||
\Version 1.0 12/31/01 (GWS) Redesigned for Tiburon environment
|
||||
*/
|
||||
/**************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtylib_h
|
||||
#define _dirtylib_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyLib DirtyLib
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
// define platform-specific options
|
||||
#ifndef DIRTYCODE_LOGGING
|
||||
#if DIRTYCODE_DEBUG
|
||||
//in debug mode logging is defaulted to on
|
||||
#define DIRTYCODE_LOGGING (1)
|
||||
#else
|
||||
//if its not specified then turn it off
|
||||
#define DIRTYCODE_LOGGING (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! define NetCrit options
|
||||
#define NETCRIT_OPTION_NONE (0) //!< default settings
|
||||
#define NETCRIT_OPTION_SINGLETHREADENABLE (1) //!< enable the crit even when in single-threaded mode
|
||||
|
||||
// debug printing routines
|
||||
#if DIRTYCODE_LOGGING
|
||||
#define NetPrintf(_x) NetPrintfCode _x
|
||||
#define NetPrintfVerbose(_x) NetPrintfVerboseCode _x
|
||||
#define NetPrintArray(_pMem, _iSize, _pTitle) NetPrintArrayCode(_pMem, _iSize, _pTitle)
|
||||
#define NetPrintMem(_pMem, _iSize, _pTitle) NetPrintMemCode(_pMem, _iSize, _pTitle)
|
||||
#define NetPrintWrap(_pString, _iWrapCol) NetPrintWrapCode(_pString, _iWrapCol)
|
||||
#define NetTimeStampEnable(_bEnableTimeStamp) NetTimeStampEnableCode(_bEnableTimeStamp)
|
||||
#else
|
||||
#define NetPrintf(_x) { }
|
||||
#define NetPrintfVerbose(_x) { }
|
||||
#define NetPrintArray(_pMem, _iSize, _pTitle) { }
|
||||
#define NetPrintMem(_pMem, _iSize, _pTitle) { }
|
||||
#define NetPrintWrap(_pString, _iWrapCol) { }
|
||||
#define NetTimeStampEnable(_bEnableTimeStamp) { }
|
||||
#endif
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct NetCritPrivT NetCritPrivT;
|
||||
|
||||
//! critical section definition
|
||||
typedef struct NetCritT
|
||||
{
|
||||
NetCritPrivT *pData;
|
||||
} NetCritT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Portable routines implemented in dirtynet.c
|
||||
*/
|
||||
|
||||
// platform-common create (called internally by NetLibCreate)
|
||||
DIRTYCODE_API void NetLibCommonInit(void);
|
||||
|
||||
// platform-common shutdown (called internally by NetLibDestroy)
|
||||
DIRTYCODE_API void NetLibCommonShutdown(void);
|
||||
|
||||
// reset net idle list
|
||||
DIRTYCODE_API void NetIdleReset(void);
|
||||
|
||||
// remove a function to the idle callback list.
|
||||
DIRTYCODE_API void NetIdleAdd(void (*proc)(void *ref), void *ref);
|
||||
|
||||
// call all the functions in the idle list.
|
||||
DIRTYCODE_API void NetIdleDel(void (*proc)(void *ref), void *ref);
|
||||
|
||||
// make sure all idle calls have completed
|
||||
DIRTYCODE_API void NetIdleDone(void);
|
||||
|
||||
// add a function to the idle callback list
|
||||
DIRTYCODE_API void NetIdleCall(void);
|
||||
|
||||
// return 32-bit hash from given input string
|
||||
DIRTYCODE_API int32_t NetHash(const char *pString);
|
||||
|
||||
// return 32-bit hash from given buffer
|
||||
DIRTYCODE_API int32_t NetHashBin(const void *pBuffer, uint32_t uLength);
|
||||
|
||||
// return 32-bit CRC from given buffer
|
||||
DIRTYCODE_API int32_t NetCrc32(const uint8_t *pBuffer, int32_t iBufLen, const uint32_t *pCrcTable);
|
||||
|
||||
// A simple psuedo-random sequence generator
|
||||
DIRTYCODE_API uint32_t NetRand(uint32_t uLimit);
|
||||
|
||||
// return time
|
||||
DIRTYCODE_API uint64_t NetTime(void);
|
||||
|
||||
// enable logging time stamp
|
||||
DIRTYCODE_API void NetTimeStampEnableCode(uint8_t bEnableTimeStamp);
|
||||
|
||||
// hook into debug output
|
||||
DIRTYCODE_API void NetPrintfHook(int32_t (*pPrintfDebugHook)(void *pParm, const char *pText), void *pParm);
|
||||
|
||||
// diagnostic output routine (do not call directly, use NetPrintf() wrapper
|
||||
DIRTYCODE_API int32_t NetPrintfCode(const char *fmt, ...);
|
||||
|
||||
// diagnostic output routine (do not call directly, use NetPrintf() wrapper
|
||||
DIRTYCODE_API void NetPrintfVerboseCode(int32_t iVerbosityLevel, int32_t iCheckLevel, const char *pFormat, ...);
|
||||
|
||||
// print input buffer with wrapping (do not call directly; use NetPrintWrap() wrapper)
|
||||
DIRTYCODE_API void NetPrintWrapCode(const char *pData, int32_t iWrapCol);
|
||||
|
||||
// print memory as hex (do not call directly; use NetPrintMem() wrapper)
|
||||
DIRTYCODE_API void NetPrintMemCode(const void *pMem, int32_t iSize, const char *pTitle);
|
||||
|
||||
// print memory as a c-style array (do not call directly; use NetPrintArray() wrapper)
|
||||
DIRTYCODE_API void NetPrintArrayCode(const void *pMem, int32_t iSize, const char *pTitle);
|
||||
|
||||
/*
|
||||
Platform-specific routines implemented in dirtynet<platform>.c
|
||||
*/
|
||||
|
||||
// initialize the network library functions.
|
||||
DIRTYCODE_API void NetLibCreate(int32_t iThreadPrio, int32_t iThreadStackSize, int32_t iThreadCpuAffinity);
|
||||
|
||||
// shutdown the network library.
|
||||
DIRTYCODE_API void NetLibDestroy(uint32_t uShutdownFlags);
|
||||
|
||||
// return an increasing tick count with millisecond scale
|
||||
DIRTYCODE_API uint32_t NetTick(void);
|
||||
|
||||
// return microsecond timer, intended for debug timing purposes only
|
||||
DIRTYCODE_API uint64_t NetTickUsec(void);
|
||||
|
||||
|
||||
/*
|
||||
The NetTickDiff() macro implies 2 steps.
|
||||
|
||||
The first step consists in substracting 2 unsigned values. When working with unsigned
|
||||
types, modular arithmetic (aka "wrap around" behavior) is taking place. It is similar
|
||||
to reading a clock.
|
||||
Adding clockwise: 9 + 4 = 1 (13 mod 12)
|
||||
Substracting counterclockwise: 1 - 4 = 9 (-3 mod 12)
|
||||
Obviously the value range here is [0,0xFFFFFFFF] and not [0,11].
|
||||
By the virtue of modular arithmetic, the difference between _uNewTime and _uOldTime is
|
||||
always valid, even in scenarios where one (or both) of the two values has just
|
||||
"wrapped around".
|
||||
|
||||
The second step consists in casting the unsigned result of step 1 into a signed
|
||||
integer. The result of that second step is the final outcome of the macro, i.e. a
|
||||
value ranging between
|
||||
-2147483648 (2's complement notation: 0x80000000) and
|
||||
2147483647 (2's complement notation: 0x7FFFFFFF)
|
||||
|
||||
Consequently, the maximum time difference (positive or negative) that can be calculated
|
||||
between _uNewTime and _uOldTime is 2147483647 ms, i.e. approximately 596,8 hours (24,9 days).
|
||||
|
||||
Any longer period of time captured with an initial call to NetTick() and a final
|
||||
call to NetTick() and then calculated by feeding both values to NetTickDiff() would
|
||||
incorrectly result in a time difference much shorter than reality.
|
||||
|
||||
If _uNewTime is more recent than _uOldTime (by not more than 596,8 hours), then
|
||||
the returned time difference will be positive.
|
||||
|
||||
If _uOldTime is more recent than _uNewTime (by not more than 596,8 hours), then
|
||||
the returned time difference will be negative.
|
||||
*/
|
||||
|
||||
// return signed difference between new tick count and old tick count (new - old)
|
||||
#define NetTickDiff(_uNewTime, _uOldTime) ((signed)((_uNewTime) - (_uOldTime)))
|
||||
|
||||
// return localtime
|
||||
DIRTYCODE_API struct tm *NetLocalTime(struct tm *pTm, uint64_t uElap);
|
||||
|
||||
// convert a platform-specific time format to generic time format
|
||||
DIRTYCODE_API struct tm *NetPlattimeToTime(struct tm *pTm, void *pPlatTime);
|
||||
|
||||
// convert a platform-specific time format to generic time format, with milliseconds
|
||||
DIRTYCODE_API struct tm *NetPlattimeToTimeMs(struct tm *pTm, int32_t *pImSec);
|
||||
|
||||
// initialize a critical section for use -- includes name for verbose debugging on some platforms
|
||||
DIRTYCODE_API int32_t NetCritInit(NetCritT *pCrit, const char *pCritName);
|
||||
|
||||
// initialize a critical section with the ability to set options (NETCRIT_OPTION_*)
|
||||
DIRTYCODE_API int32_t NetCritInit2(NetCritT *pCrit, const char *pCritName, uint32_t uFlags);
|
||||
|
||||
// release resources and destroy critical section
|
||||
DIRTYCODE_API void NetCritKill(NetCritT *pCrit);
|
||||
|
||||
// attempt to gain access to critical section
|
||||
DIRTYCODE_API int32_t NetCritTry(NetCritT *pCrit);
|
||||
|
||||
// enter a critical section, blocking if needed
|
||||
DIRTYCODE_API void NetCritEnter(NetCritT *pCrit);
|
||||
|
||||
// leave a critical section
|
||||
DIRTYCODE_API void NetCritLeave(NetCritT *pCrit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtylib_h
|
||||
|
180
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtymem.h
vendored
Normal file
180
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtymem.h
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtymem.h
|
||||
|
||||
\Description
|
||||
DirtySock memory allocation routines.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 10/12/2005 (jbrookes) First Version
|
||||
\Version 11/19/2008 (mclouatre) Adding pMemGroupUserData to mem groups
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtymem_h
|
||||
#define _dirtymem_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyMem DirtyMem
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*!
|
||||
All DirtySock modules have their memory identifiers defined here.
|
||||
*/
|
||||
// comm modules
|
||||
#define COMMSRP_MEMID ('csrp')
|
||||
#define COMMUDP_MEMID ('cudp')
|
||||
|
||||
// crypt modules
|
||||
#define CRYPTRSA_MEMID ('crsa')
|
||||
#define CRYPTRAND_MEMID ('rand')
|
||||
|
||||
// dirtysock modules
|
||||
#define DIRTYAUTH_MEMID ('dath')
|
||||
#define DIRTYCERT_MEMID ('dcrt')
|
||||
#define DIRTYCM_MEMID ('dhcm')
|
||||
#define DIRTYSESSMGR_MEMID ('dsmg')
|
||||
#define DIRTYWEBAPI_MEMID ('weba')
|
||||
#define DIRTYEVENT_DISP_MEMID ('semd')
|
||||
#define SOCKET_MEMID ('dsoc')
|
||||
#define NETCONN_MEMID ('ncon')
|
||||
#define DIRTYTHREAD_MEMID ('dthr')
|
||||
|
||||
// game modules
|
||||
#define CONNAPI_MEMID ('conn')
|
||||
#define NETGAMEDIST_MEMID ('ngdt')
|
||||
#define NETGAMEDISTSERV_MEMID ('ngds')
|
||||
#define NETGAMELINK_MEMID ('nglk')
|
||||
#define NETGAMEUTIL_MEMID ('ngut')
|
||||
|
||||
// graph modules
|
||||
#define DIRTYGRAPH_MEMID ('dgph')
|
||||
#define DIRTYJPG_MEMID ('djpg')
|
||||
#define DIRTYPNG_MEMID ('dpng')
|
||||
|
||||
// misc modules
|
||||
#define LOBBYLAN_MEMID ('llan')
|
||||
#define USERAPI_MEMID ('uapi')
|
||||
#define USERLISTAPI_MEMID ('ulst')
|
||||
#define WEBLOG_MEMID ('wlog')
|
||||
#define PRIVILEGEAPI_MEMID ('priv')
|
||||
|
||||
// proto modules
|
||||
#define PROTOADVT_MEMID ('padv')
|
||||
#define PROTOHTTP_MEMID ('phtp')
|
||||
#define HTTPSERV_MEMID ('hsrv')
|
||||
#define HTTPMGR_MEMID ('hmgr')
|
||||
#define PROTOMANGLE_MEMID ('pmgl')
|
||||
#define PROTOPING_MEMID ('ppng')
|
||||
#define PINGMGR_MEMID ('lpmg')
|
||||
#define PROTOSSL_MEMID ('pssl')
|
||||
#define PROTOSTREAM_MEMID ('pstr')
|
||||
#define PROTOTUNNEL_MEMID ('ptun')
|
||||
#define PROTOUDP_MEMID ('pudp')
|
||||
#define PROTOUPNP_MEMID ('pupp')
|
||||
#define PROTOWEBSOCKET_MEMID ('webs')
|
||||
|
||||
// util modules
|
||||
#define DISPLIST_MEMID ('ldsp')
|
||||
#define HASHER_MEMID ('lhsh')
|
||||
#define SORT_MEMID ('lsor')
|
||||
#define HPACK_MEMID ('hpak')
|
||||
#define PROTOBUF_MEMID ('pbuf')
|
||||
|
||||
// qos module
|
||||
#define QOSAPI_MEMID ('dqos')
|
||||
#define QOS_CLIENT_MEMID ('qosc')
|
||||
#define QOS_COMMON_MEMID ('qcom')
|
||||
|
||||
// voip module
|
||||
#define VOIP_MEMID ('voip')
|
||||
#define VOIPNARRATE_MEMID ('vnar')
|
||||
#define VOIPTRANSCRIBE_MEMID ('vscr')
|
||||
#define VOIP_PLATFORM_MEMID ('vplt') //<! memory allocated by 1st-party voip lib (xone: game chat 2, others: unused)
|
||||
|
||||
// voiptunnel module
|
||||
#define VOIPTUNNEL_MEMID ('vtun')
|
||||
|
||||
// web modules
|
||||
#define NETRSRC_MEMID ('nrsc')
|
||||
#define WEBOFFER_MEMID ('webo')
|
||||
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
#if !DIRTYCODE_DEBUG
|
||||
#define DirtyMemDebugAlloc(_pMem, _iSize, _iMemModule, _iMemGroup, _pMemGroupUserData) {;}
|
||||
#define DirtyMemDebugFree(_pMem, _iSize, _iMemModule, _iMemGroup, _pMemGroupUserData) {;}
|
||||
#endif
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
//#if defined(DIRTYCODE_DLL)
|
||||
|
||||
//! Used in the dll mode to specify DirtyMemAlloc function
|
||||
typedef void *(DirtyMemAllocT)(int32_t iSize, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
//! Used in the dll mode to specify DirtyMemFree function
|
||||
typedef void (DirtyMemFreeT)(void *pMem, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
//#endif
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! enter memory group
|
||||
DIRTYCODE_API void DirtyMemGroupEnter(int32_t iGroup, void *pMemGroupUserData);
|
||||
|
||||
//! leave memory group
|
||||
DIRTYCODE_API void DirtyMemGroupLeave(void);
|
||||
|
||||
//! get current memory group
|
||||
DIRTYCODE_API void DirtyMemGroupQuery(int32_t *pMemGroup, void **ppMemGroupUserData);
|
||||
|
||||
#if DIRTYCODE_DEBUG
|
||||
//! display memory allocation info to debug output (debug only)
|
||||
DIRTYCODE_API void DirtyMemDebugAlloc(void *pMem, int32_t iSize, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
//! display memory free info to debug output (debug only)
|
||||
DIRTYCODE_API void DirtyMemDebugFree(void *pMem, int32_t iSize, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Memory allocation routines - not implemented in the lib; these must be supplied by the user.
|
||||
In DLL mode use DirtyMemFuncSet to set the DirtyMemAlloc and DirtyMemFree before using any DS functions.
|
||||
If its not set default allocator will be used.
|
||||
*/
|
||||
|
||||
#if defined(DIRTYCODE_DLL)
|
||||
//! Use to set the Memory Alloc and Free functions
|
||||
DIRTYCODE_API void DirtyMemFuncSet(DirtyMemAllocT *pMemAlloc, DirtyMemFreeT *pMemFree);
|
||||
#endif
|
||||
|
||||
//! allocate memory
|
||||
DIRTYCODE_API void *DirtyMemAlloc(int32_t iSize, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
//! free memory
|
||||
DIRTYCODE_API void DirtyMemFree(void *pMem, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtymem_h
|
||||
|
65
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtynames.h
vendored
Normal file
65
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtynames.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File dirtynames.h
|
||||
|
||||
\Description
|
||||
This module provides helper functions for manipulating persona and master
|
||||
account name strings.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2002-2003
|
||||
|
||||
\Version 1.0 12/10/03 (DBO) First Version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtynames_h
|
||||
#define _dirtynames_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyNames DirtyNames
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// compare two names for equality. Ignore case and strip non-printable ascii characters.
|
||||
DIRTYCODE_API int32_t DirtyUsernameCompare(const char *pName1, const char *pName2);
|
||||
|
||||
// determine if pMatch is a substring of pSrc. Ignore case and strip non-printable ascii characters.
|
||||
DIRTYCODE_API int32_t DirtyUsernameSubstr(const char *pSrc, const char *pMatch);
|
||||
|
||||
// generate the hash code for the given name. Ignore case and strip non-printable ascii characters.
|
||||
DIRTYCODE_API uint32_t DirtyUsernameHash(const char *pName);
|
||||
|
||||
// create the canonical form of the given name. Ignore case and strip non-printable ascii characters.
|
||||
DIRTYCODE_API int32_t DirtyNameCreateCanonical(const char *pName, char * pCanonical, size_t uLen);
|
||||
|
||||
// convert a char to xlat table index using its ascii char representation.
|
||||
int32_t toXlatIndex(const char str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtynames_h
|
||||
|
360
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtynet.h
vendored
Normal file
360
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtynet.h
vendored
Normal file
@ -0,0 +1,360 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File dirtynet.h
|
||||
|
||||
\Description
|
||||
Platform independent interface to network layers. Based on BSD sockets, but with
|
||||
performance modifications. Allows truly portable modules to be written and moved
|
||||
to different platforms needing only different support wrappers (no change to
|
||||
actual network modes).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2001-2014
|
||||
|
||||
\Version 0.5 08/01/2001 (gschaefer) First Version
|
||||
\Version 1.1 01/02/2002 (gschaefer) First Release
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtynet_h
|
||||
#define _dirtynet_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyNet DirtyNet
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*
|
||||
Include system socket/inet headers, and/or define what we need ourselves
|
||||
*/
|
||||
#if defined(DIRTYCODE_NX)
|
||||
#include <nn/socket/sys/cdefs.h>
|
||||
#include <nn/socket/netinet/in.h>
|
||||
#include <nn/socket/sys/types.h>
|
||||
#include <nn/socket/sys/socket.h>
|
||||
|
||||
#elif !defined(DIRTYCODE_XBOXONE) && !defined(DIRTYCODE_PC) && !defined(DIRTYCODE_GDK)
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h> /* struct sockaddr_in */
|
||||
#include <arpa/inet.h> /* struct in_addr */
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
#define IPPROTO_IPV4 4
|
||||
#ifdef INADDR_BROADCAST
|
||||
#undef INADDR_BROADCAST
|
||||
#endif
|
||||
#ifdef INADDR_ANY
|
||||
#undef INADDR_ANY
|
||||
#define INADDR_ANY 0x00000000
|
||||
#endif
|
||||
#ifdef INADDR_LOOPBACK
|
||||
#undef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK 0x7f000001
|
||||
#endif
|
||||
|
||||
#endif // defined(DIRTYCODE_PS4)
|
||||
|
||||
#else // DIRTYCODE_PC or DIRTYCODE_XBOXONE
|
||||
|
||||
#if !defined(_WINSOCKAPI_) || defined(EA_FORCE_WINSOCK2_INCLUDE) // if <winsock.h> was included, skip, unless we want to force include it
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif // _WINSOCKAPI_
|
||||
|
||||
#endif // including system socket/inet headers
|
||||
|
||||
|
||||
/*
|
||||
IPv6 definitions for common code for platforms that don't have them,
|
||||
until if/when they are available natively
|
||||
*/
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
#if !defined(s6_addr) // not sure what ipv6 definitions will look like but this is a likely definition we can check for
|
||||
struct in6_addr {
|
||||
uint8_t s6_addr[16]; /* IPv6 address */
|
||||
};
|
||||
|
||||
struct sockaddr_in6 {
|
||||
uint16_t sin6_family; /* AF_INET6 */
|
||||
uint16_t sin6_port; /* port number */
|
||||
uint32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
uint32_t sin6_scope_id; /* Scope ID (new in 2.4) */
|
||||
};
|
||||
#endif // !defined(s6_addr)
|
||||
#endif // DIRTYCODE_PS4
|
||||
|
||||
|
||||
/*
|
||||
DirtyNet specific defines
|
||||
*/
|
||||
|
||||
#define SOCK_NORECV 1 //!< caller does not want to receive more data
|
||||
#define SOCK_NOSEND 2 //!< caller does not want to send more data
|
||||
|
||||
#if !defined (DIRTYCODE_NX)
|
||||
#ifndef INADDR_BROADCAST
|
||||
#define INADDR_BROADCAST 0xffffffff
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CALLB_NONE 0 //!< no callback
|
||||
#define CALLB_SEND 1 //!< call when we can send
|
||||
#define CALLB_RECV 2 //!< call when we can receive
|
||||
|
||||
#define SOCKLOOK_LOCALADDR "*"
|
||||
|
||||
#define SOCKLOOK_FLAGS_ALLOWXDNS (1)
|
||||
|
||||
//! maximum udp packet size we can receive (constrained by Xbox 360 max VDP packet size)
|
||||
#define SOCKET_MAXUDPRECV (1264)
|
||||
|
||||
//! maximum number of virtual ports that can be specified
|
||||
#define SOCKET_MAXVIRTUALPORTS (32)
|
||||
|
||||
// Errors
|
||||
|
||||
#define SOCKERR_NONE 0 //!< no error
|
||||
#define SOCKERR_CLOSED -1 //!< the socket is closed
|
||||
#define SOCKERR_NOTCONN -2 //!< the socket is not connected
|
||||
#define SOCKERR_BLOCKED -3 //!< operation would result in blocking
|
||||
#define SOCKERR_ADDRESS -4 //!< the address is invalid
|
||||
#define SOCKERR_UNREACH -5 //!< network cannot be accessed by this host
|
||||
#define SOCKERR_REFUSED -6 //!< connection refused by the recipient
|
||||
#define SOCKERR_OTHER -7 //!< unclassified error
|
||||
#define SOCKERR_NOMEM -8 //!< out of memory
|
||||
#define SOCKERR_NORSRC -9 //!< out of resources
|
||||
#define SOCKERR_UNSUPPORT -10 //!< unsupported operation
|
||||
#define SOCKERR_INVALID -11 //!< resource or operation is invalid
|
||||
#define SOCKERR_ADDRINUSE -12 //!< address already in use
|
||||
#define SOCKERR_CONNRESET -13 //!< connection has been reset
|
||||
#define SOCKERR_BADPIPE -14 //!< EBADF or EPIPE
|
||||
|
||||
//! error occured when trying to map address using SocketAddrMapAddress (+ip6)/SocketAddrRemapAddress (~ip6)
|
||||
#define SOCKMAP_ERROR (-1)
|
||||
|
||||
//! maximum number of send callbacks supported (internal use only - needs to be public for DirtyCast stress tester)
|
||||
#define SOCKET_MAXSENDCALLBACKS (8)
|
||||
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*
|
||||
Macros used to write into a sockaddr structure take into account the fact that the sa_data field is defined
|
||||
as an array of signed char on Windows and an array of unsigned char on other platforms. Doing this is required
|
||||
to avoid C4365 warning occurring when these macros are used in .cpp files. (The same warning would not occur
|
||||
when using these macros in .c files. The windows compiler (cl.exe) only warns about C4365 with .cpp files.
|
||||
*/
|
||||
#if defined(DIRTYCODE_XBOXONE) || defined(DIRTYCODE_PC)
|
||||
#define SA_DATA_TYPE char
|
||||
#else
|
||||
#define SA_DATA_TYPE unsigned char
|
||||
#endif
|
||||
|
||||
//! init a sockaddr to zero and set its family type
|
||||
#define SockaddrInit(addr,fam) { (addr)->sa_family = (fam); ds_memclr((addr)->sa_data, sizeof((addr)->sa_data)); }
|
||||
|
||||
//! get the port in host format from sockaddr
|
||||
#define SockaddrInGetPort(addr) ((((unsigned char)(addr)->sa_data[0])<<8)|(((unsigned char)(addr)->sa_data[1])<<0))
|
||||
|
||||
//! set the port in host format in a sockaddr
|
||||
#define SockaddrInSetPort(addr,val) { (addr)->sa_data[0] = (SA_DATA_TYPE)(((val)>>8)&0xff); (addr)->sa_data[1] = (SA_DATA_TYPE)((val)&0xff); }
|
||||
|
||||
//! get the address in host format from sockaddr
|
||||
#define SockaddrInGetAddr(addr) (((((((unsigned char)((addr)->sa_data[2])<<8)|(unsigned char)((addr)->sa_data[3]))<<8)|(unsigned char)((addr)->sa_data[4]))<<8)|(unsigned char)((addr)->sa_data[5]))
|
||||
|
||||
//! set the address in host format in a sockaddr
|
||||
#define SockaddrInSetAddr(addr,val) { uint32_t val2 = (val); (addr)->sa_data[5] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[4] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[3] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[2] = (SA_DATA_TYPE)val2; }
|
||||
|
||||
//! get the misc field in host format from sockaddr
|
||||
#define SockaddrInGetMisc(addr) (((((((unsigned char)((addr)->sa_data[6])<<8)|(unsigned char)((addr)->sa_data[7]))<<8)|(unsigned char)((addr)->sa_data[8]))<<8)|(unsigned char)((addr)->sa_data[9]))
|
||||
|
||||
//! set the misc field in host format in a sockaddr
|
||||
#define SockaddrInSetMisc(addr,val) { uint32_t val2 = (val); (addr)->sa_data[9] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[8] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[7] = (SA_DATA_TYPE)val2; val2 >>= 8; (addr)->sa_data[6] = (SA_DATA_TYPE)val2; }
|
||||
|
||||
//! detect loopback address (family independent)
|
||||
#define SockaddrIsLoopback(addr) (( ((addr)->sa_family == AF_INET) && ((addr)->sa_data[0] == 127) && ((addr)->sa_data[1] == 0) && ((addr)->sa_data[2] == 0) && ((addr)->sa_data[3] == 1) ))
|
||||
|
||||
/*
|
||||
sockaddr_v6 helpers
|
||||
*/
|
||||
|
||||
//! init a sockaddr6 to zero and set its family type
|
||||
#define SockaddrInit6(addr,fam) { ds_memclr(addr, sizeof(*(addr))); (addr)->sin6_family = (fam); }
|
||||
|
||||
//! get IPv6 address from IPv4-mapped IPv6 address, also works for NAT64
|
||||
#define SockaddrIn6GetAddr4(addr) (((((((uint8_t)((addr)->sin6_addr.s6_addr[12])<<8)|(uint8_t)((addr)->sin6_addr.s6_addr[13]))<<8)|(uint8_t)((addr)->sin6_addr.s6_addr[14]))<<8)|(uint8_t)((addr)->sin6_addr.s6_addr[15]))
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
|
||||
// basic socket type is a pointer
|
||||
typedef struct SocketT SocketT;
|
||||
|
||||
//! a host lookup structure -- uses a callback
|
||||
//! system to determine when lookup has finished
|
||||
typedef struct HostentT
|
||||
{
|
||||
int32_t done; //!< public: indicates when lookup is complete
|
||||
uint32_t addr; //!< public: resolved host address
|
||||
|
||||
int32_t (*Done)(struct HostentT *); //!< public: callback to indicate completion status
|
||||
void (*Free)(struct HostentT *); //!< public: callback to release Hostent structure
|
||||
|
||||
char name[256]; //!< private (the maximum DNS name length is 253 characters)
|
||||
int32_t sema; //!< private
|
||||
int32_t thread; //!< private
|
||||
void* pData; //!< private
|
||||
uint32_t timeout; //!< private
|
||||
struct HostentT *pNext; //!< private
|
||||
int32_t refcount; //!< private
|
||||
} HostentT;
|
||||
|
||||
//! global socket send callback
|
||||
typedef int32_t (SocketSendCallbackT)(SocketT *pSocket, int32_t iType, const uint8_t *pData, int32_t iDataSize, const struct sockaddr *pTo, void *pCallref);
|
||||
|
||||
//! socket send callback entry (internal use only - needs to be public for DirtyCast stress tester)
|
||||
typedef struct SocketSendCallbackEntryT
|
||||
{
|
||||
SocketSendCallbackT *pSendCallback; //!< global send callback
|
||||
void *pSendCallref; //!< user callback data
|
||||
} SocketSendCallbackEntryT;
|
||||
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
platform independent functions, implemented in dirtynet.c
|
||||
*/
|
||||
|
||||
// compare two sockaddr structures
|
||||
DIRTYCODE_API int32_t SockaddrCompare(const struct sockaddr *pAddr1, const struct sockaddr *pAddr2);
|
||||
|
||||
// set the address in text format in a sockaddr
|
||||
DIRTYCODE_API int32_t SockaddrInSetAddrText(struct sockaddr *pAddr, const char *pStr);
|
||||
|
||||
// get the address in text format from sockaddr
|
||||
DIRTYCODE_API char *SockaddrInGetAddrText(const struct sockaddr *pAddr, char *pStr, int32_t iLen);
|
||||
|
||||
// parse address:port combination
|
||||
DIRTYCODE_API int32_t SockaddrInParse(struct sockaddr *pAddr, const char *pParse);
|
||||
|
||||
// parse address:port:port combination into separate components
|
||||
DIRTYCODE_API int32_t SockaddrInParse2(uint32_t *pAddr, int32_t *pPort, int32_t *pPort2, const char *pParse);
|
||||
|
||||
// convert 32-bit internet address into textual form
|
||||
DIRTYCODE_API char *SocketInAddrGetText(uint32_t uAddr, char *pStr, int32_t iLen);
|
||||
|
||||
// convert textual internet address into 32-bit integer form
|
||||
DIRTYCODE_API int32_t SocketInTextGetAddr(const char *pAddrText);
|
||||
|
||||
// convert int16_t from host to network byte order
|
||||
DIRTYCODE_API uint16_t SocketHtons(uint16_t uAddr);
|
||||
|
||||
// convert int32_t from host to network byte order
|
||||
DIRTYCODE_API uint32_t SocketHtonl(uint32_t uAddr);
|
||||
|
||||
// convert int16_t from network to host byte order
|
||||
DIRTYCODE_API uint16_t SocketNtohs(uint16_t uAddr);
|
||||
|
||||
// convert int32_t from network to host byte order.
|
||||
DIRTYCODE_API uint32_t SocketNtohl(uint32_t uAddr);
|
||||
|
||||
/*
|
||||
platform dependent functions, implemented in dirtynet<platform>.c
|
||||
*/
|
||||
|
||||
// create new instance of socket interface module
|
||||
DIRTYCODE_API int32_t SocketCreate(int32_t iThreadPrio, int32_t iThreadStackSize, int32_t iThreadCpuAffinity);
|
||||
|
||||
// release resources and destroy module.
|
||||
DIRTYCODE_API int32_t SocketDestroy(uint32_t uShutdownFlags);
|
||||
|
||||
// create a new transfer endpoint
|
||||
DIRTYCODE_API SocketT *SocketOpen(int32_t af, int32_t type, int32_t protocol);
|
||||
|
||||
// perform partial/complete shutdown of socket
|
||||
DIRTYCODE_API int32_t SocketShutdown(SocketT *pSocket, int32_t how);
|
||||
|
||||
// close a socket
|
||||
DIRTYCODE_API int32_t SocketClose(SocketT *pSocket);
|
||||
|
||||
// import a socket - may be SocketT pointer or sony socket ref
|
||||
DIRTYCODE_API SocketT *SocketImport(intptr_t uSockRef);
|
||||
|
||||
// release an imported socket
|
||||
DIRTYCODE_API void SocketRelease(SocketT *pSocket);
|
||||
|
||||
// bind a local address/port to a socket
|
||||
DIRTYCODE_API int32_t SocketBind(SocketT *pSocket, const struct sockaddr *name, int32_t namelen);
|
||||
|
||||
// return information about an existing socket.
|
||||
DIRTYCODE_API int32_t SocketInfo(SocketT *pSocket, int32_t iInfo, int32_t iData, void *pBuf, int32_t iLen);
|
||||
|
||||
// send a control message to the dirtysock layer
|
||||
DIRTYCODE_API int32_t SocketControl(SocketT *pSocket, int32_t option, int32_t data1, void *data2, void *data3);
|
||||
|
||||
// start listening for an incoming connection on the socket
|
||||
DIRTYCODE_API int32_t SocketListen(SocketT *pSocket, int32_t backlog);
|
||||
|
||||
// attempt to accept an incoming connection from a
|
||||
DIRTYCODE_API SocketT *SocketAccept(SocketT *pSocket, struct sockaddr *addr, int32_t *addrlen);
|
||||
|
||||
// initiate a connection attempt to a remote host
|
||||
DIRTYCODE_API int32_t SocketConnect(SocketT *pSocket, struct sockaddr *name, int32_t namelen);
|
||||
|
||||
// send data to a remote host
|
||||
DIRTYCODE_API int32_t SocketSendto(SocketT *pSocket, const char *buf, int32_t len, int32_t flags, const struct sockaddr *to, int32_t tolen);
|
||||
|
||||
// same as SocketSendto() with "to" set to NULL
|
||||
#define SocketSend(_pSocket, _pBuf, iLen, iFlags) SocketSendto(_pSocket, _pBuf, iLen, iFlags, NULL, 0)
|
||||
|
||||
// receive data from a remote host
|
||||
DIRTYCODE_API int32_t SocketRecvfrom(SocketT *pSocket, char *buf, int32_t len, int32_t flags, struct sockaddr *from, int32_t *fromlen);
|
||||
|
||||
// same as SocketRecvfrom() with "from" set to NULL.
|
||||
#define SocketRecv(_pSocket, pBuf, iLen, iFlags) SocketRecvfrom(_pSocket, pBuf, iLen, iFlags, NULL, 0)
|
||||
|
||||
// register a callback routine for notification of socket events
|
||||
DIRTYCODE_API int32_t SocketCallback(SocketT *pSocket, int32_t flags, int32_t timeout, void *ref, int32_t (*proc)(SocketT *pSocket, int32_t flags, void *ref));
|
||||
|
||||
// return the host address that would be used in order to communicate with the given destination address.
|
||||
DIRTYCODE_API int32_t SocketHost(struct sockaddr *host, int32_t hostlen, const struct sockaddr *dest, int32_t destlen);
|
||||
|
||||
// lookup a host by name and return the corresponding Internet address
|
||||
DIRTYCODE_API HostentT *SocketLookup(const char *text, int32_t timeout);
|
||||
|
||||
// lookup a host by name and return the corresponding Internet address, with flags
|
||||
#define SocketLookup2(_text, _timeout, _flags) SocketLookup(_text, _timeout)
|
||||
|
||||
// invoke all registered send callbacks (internal use only - needs to be public for DirtyCast stress tester)
|
||||
int32_t SocketSendCallbackInvoke(SocketSendCallbackEntryT aCbEntries[], SocketT *pSocket, int32_t iType, const char *pBuf, int32_t iLen, const struct sockaddr *pTo);
|
||||
|
||||
|
||||
// return "external" local address
|
||||
DIRTYCODE_API uint32_t SocketGetLocalAddr(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtynet_h
|
||||
|
||||
|
120
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtysessionmanager.h
vendored
Normal file
120
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtysessionmanager.h
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File dirtysessionmanager.h
|
||||
|
||||
\Description
|
||||
DirtySessionManager handles the creation, joinning and leaving of
|
||||
a session. Offers mechanism to encode and decode the session, and does some
|
||||
session flags management
|
||||
|
||||
\Notes
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2003-2007
|
||||
|
||||
\Version 1.0 11/03/2003 (jbrookes) First Version
|
||||
\Version 2.0 11/04/2007 (jbrookes) Removed from ProtoMangle namespace, cleanup
|
||||
\Version 2.2 10/26/2009 (mclouatre) Renamed from core/include/dirtysessionmanager.h to core/include/xenon/dirtysessionmanagerxenon.h
|
||||
\Version 2.3 03/26/2013 (cvienneau) Renamed from core/include/xenon/dirtysessionmanagerxenon.h to core/include/dirtysessionmanager.h
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtysessionmanager_h
|
||||
#define _dirtysessionmanager_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtySessionManager DirtySessionManager
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyaddr.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define DIRTYSESSIONMANAGER_FLAG_PUBLICSLOT (1)
|
||||
#define DIRTYSESSIONMANAGER_FLAG_PRIVATESLOT (2)
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
#define DIRTY_SESSION_GAME_MODE_LENGTH 257
|
||||
#endif
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct DirtySessionManagerRefT DirtySessionManagerRefT;
|
||||
#if DIRTYCODE_DEBUG
|
||||
//! true skill values struct
|
||||
typedef struct DirtySessionManagerTrueSkillRefT //!< true skill struct used for debugging
|
||||
{
|
||||
double dMu;
|
||||
double dSigma;
|
||||
} DirtySessionManagerTrueSkillRefT;
|
||||
#endif
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
//!< data that we control within the binary blob portion of the session
|
||||
typedef struct DirtySessionManagerBinaryHeaderT
|
||||
{
|
||||
int64_t iLobbyId;
|
||||
int64_t iGameType;
|
||||
} DirtySessionManagerBinaryHeaderT;
|
||||
|
||||
//!< data that we control within the changeable binary blob portion of the session
|
||||
typedef struct DirtySessionManagerChangeableBinaryHeaderT
|
||||
{
|
||||
char strGameMode[DIRTY_SESSION_GAME_MODE_LENGTH];
|
||||
} DirtySessionManagerChangeableBinaryHeaderT;
|
||||
#endif
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate module state and prepare for use
|
||||
DirtySessionManagerRefT *DirtySessionManagerCreate(void);
|
||||
|
||||
// destroy the module and release its state
|
||||
void DirtySessionManagerDestroy(DirtySessionManagerRefT *pRef);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
void DirtySessionManagerUpdate(DirtySessionManagerRefT *pRef);
|
||||
|
||||
// join one (or many) remote player(s) by specifying the session and type of slot to use
|
||||
void DirtySessionManagerConnect(DirtySessionManagerRefT *pRef, const char **pSessID, uint32_t *pSlot, uint32_t uCount);
|
||||
|
||||
// dirtysessionmanager control
|
||||
int32_t DirtySessionManagerControl(DirtySessionManagerRefT *pRef, int32_t iControl, int32_t iValue, int32_t iValue2, const void *pValue);
|
||||
|
||||
// get module status based on selector
|
||||
int32_t DirtySessionManagerStatus(DirtySessionManagerRefT *pRef, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// get module status based on selector
|
||||
int32_t DirtySessionManagerStatus2(DirtySessionManagerRefT *pRef, int32_t iSelect, int32_t iValue, int32_t iValue2, int32_t iValue3, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// encode
|
||||
void DirtySessionManagerEncodeSession(char *pBuffer, int32_t iBufSize, const void *pSessionInfo);
|
||||
|
||||
// decode
|
||||
void DirtySessionManagerDecodeSession(void *pSessionInfo, const char *pBuffer);
|
||||
|
||||
// create the session (previously the 'sess' control selector)
|
||||
int32_t DirtySessionManagerCreateSess(DirtySessionManagerRefT *pRef, uint32_t bRanked, uint32_t *uUserFlags, const char *pSession, DirtyAddrT *pLocalAddrs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtysessionmanager_h
|
||||
|
||||
|
78
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtythread.h
vendored
Normal file
78
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtythread.h
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*H**************************************************************************************/
|
||||
/*!
|
||||
\File dirtythread.h
|
||||
|
||||
\Description
|
||||
Provide threading library functions for use by network layer code.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017
|
||||
|
||||
\Version 09/27/17 (eesponda)
|
||||
*/
|
||||
/**************************************************************************************H*/
|
||||
|
||||
#ifndef _dirtythread_h
|
||||
#define _dirtythread_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyThread DirtyThread
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
// configuration for the thread
|
||||
typedef struct DirtyThreadConfigT
|
||||
{
|
||||
int32_t iPriority; //!< priority of the thread, platform dependent
|
||||
int32_t iAffinity; //!< affinity mask
|
||||
const char *pName; //!< name of the thread
|
||||
int32_t iVerbosity; //!< verbosity of logging information (deprecated)
|
||||
} DirtyThreadConfigT;
|
||||
|
||||
// function that gets run on the thread
|
||||
typedef void (DirtyRunnableFunctionT)(void* pUserData);
|
||||
|
||||
// opaque module ref
|
||||
typedef struct DirtyConditionRefT DirtyConditionRefT;
|
||||
|
||||
// forward declaration
|
||||
typedef struct NetCritT NetCritT;
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// start the thread
|
||||
DIRTYCODE_API int32_t DirtyThreadCreate(DirtyRunnableFunctionT *pFunction, void *pUserData, const DirtyThreadConfigT *pConfig);
|
||||
|
||||
// get thread id
|
||||
DIRTYCODE_API const char *DirtyThreadGetThreadId(char *pBuffer, int32_t iBufSize);
|
||||
|
||||
// create a condition variable with name
|
||||
DIRTYCODE_API DirtyConditionRefT *DirtyConditionCreate(const char *pName);
|
||||
|
||||
// destroy the condition
|
||||
DIRTYCODE_API void DirtyConditionDestroy(DirtyConditionRefT *pCondition);
|
||||
|
||||
// wait for a condition
|
||||
DIRTYCODE_API void DirtyConditionWait(DirtyConditionRefT *pCondition, NetCritT *pCrit);
|
||||
|
||||
// signal the condition
|
||||
DIRTYCODE_API uint8_t DirtyConditionSignal(DirtyConditionRefT *pCondition);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtythread_h
|
66
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyuser.h
vendored
Normal file
66
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/dirtyuser.h
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtyuser.h
|
||||
|
||||
\Description
|
||||
Definition for portable user type.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013
|
||||
|
||||
\Version 04/25/13 (mclouatre) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtyuser_h
|
||||
#define _dirtyuser_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyUser DirtyUser
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define DIRTYUSER_NATIVEUSER_MAXLEN (64)
|
||||
#define DIRTYUSER_NATIVEUSER_MAXSIZE (DIRTYUSER_NATIVEUSER_MAXLEN + 1)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque user type
|
||||
typedef struct DirtyUserT
|
||||
{
|
||||
char strNativeUser[DIRTYUSER_NATIVEUSER_MAXSIZE];
|
||||
} DirtyUserT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! convert a DirtyUserT to native format
|
||||
DIRTYCODE_API uint32_t DirtyUserToNativeUser(void *pOutput, int32_t iBufLen, const DirtyUserT *pUser);
|
||||
|
||||
//! convert a native format to a DirtyUserT
|
||||
DIRTYCODE_API uint32_t DirtyUserFromNativeUser(DirtyUserT *pUser, const void *pInput);
|
||||
|
||||
//! compare two opaque users for equality (same=TRUE, different=FALSE)
|
||||
DIRTYCODE_API int32_t DirtyUserCompare(DirtyUserT *pUser1, DirtyUserT *pUser2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtyuser_h
|
160
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/netconn.h
vendored
Normal file
160
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/netconn.h
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File netconn.h
|
||||
|
||||
\Description
|
||||
Provides network setup and teardown support. Does not actually create any
|
||||
kind of network connections.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2001-2009
|
||||
|
||||
\Version 03/12/2001 (gschaefer) First Version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _netconn_h
|
||||
#define _netconn_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetConnDefs NetConnDefs
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/netconndefs.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! maximum number of local users
|
||||
#if defined(DIRTYCODE_XBOXONE)
|
||||
#define NETCONN_MAXLOCALUSERS (16)
|
||||
#elif defined(DIRTYCODE_NX)
|
||||
#define NETCONN_MAXLOCALUSERS (8)
|
||||
#else
|
||||
#define NETCONN_MAXLOCALUSERS (4)
|
||||
#endif
|
||||
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct NetConnUserDataT
|
||||
{
|
||||
char strName[16];
|
||||
void *pRawData1;
|
||||
void *pRawData2;
|
||||
} NetConnUserDataT;
|
||||
|
||||
//! account structure
|
||||
typedef struct NetConnAccountInfoT
|
||||
{
|
||||
int64_t iAccountId; //!< the EA account Id of the user
|
||||
int64_t iPersonaId; //!< the EA persona Id of the user
|
||||
} NetConnAccountInfoT;
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
typedef void (NetConnNpStateCallbackT)(int32_t /* SceUserServiceUserId */ userId, int32_t /* SceNpState */ state, void* pUserData);
|
||||
#endif
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// bring the network connection module to life
|
||||
DIRTYCODE_API int32_t NetConnStartup(const char *pParams);
|
||||
|
||||
// query the list of available connection configurations
|
||||
DIRTYCODE_API int32_t NetConnQuery(const char *pDevice, NetConfigRecT *pList, int32_t iSize);
|
||||
|
||||
// bring the networking online with a specific configuration
|
||||
DIRTYCODE_API int32_t NetConnConnect(const NetConfigRecT *pConfig, const char *pParms, int32_t iData);
|
||||
|
||||
// set module behavior based on input selector
|
||||
DIRTYCODE_API int32_t NetConnControl(int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue, void *pValue2);
|
||||
|
||||
// check general network connection status (added param)
|
||||
DIRTYCODE_API int32_t NetConnStatus(int32_t iKind, int32_t iData, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// return MAC address in textual form
|
||||
DIRTYCODE_API const char *NetConnMAC(void);
|
||||
|
||||
// take down the network connection
|
||||
DIRTYCODE_API int32_t NetConnDisconnect(void);
|
||||
|
||||
// shutdown the network code and return to idle state
|
||||
DIRTYCODE_API int32_t NetConnShutdown(uint32_t uShutdownFlags);
|
||||
|
||||
// return elapsed time in milliseconds
|
||||
DIRTYCODE_API uint32_t NetConnElapsed(void);
|
||||
|
||||
// sleep the application (burn cycles) for some number of milliseconds
|
||||
DIRTYCODE_API void NetConnSleep(int32_t iMilliSecs);
|
||||
|
||||
// add an idle handler that will get called periodically
|
||||
DIRTYCODE_API int32_t NetConnIdleAdd(void (*proc)(void *data, uint32_t tick), void *data);
|
||||
|
||||
// remove a previously added idle handler
|
||||
DIRTYCODE_API int32_t NetConnIdleDel(void (*proc)(void *data, uint32_t tick), void *data);
|
||||
|
||||
// provide "life" to the network code
|
||||
DIRTYCODE_API void NetConnIdle(void);
|
||||
|
||||
// shut down netconn idle handler
|
||||
// NOTE: this is meant for internal use only, and should not be called by applications directly
|
||||
DIRTYCODE_API void NetConnIdleShutdown(void);
|
||||
|
||||
// Enable or disable the timing of netconnidles
|
||||
DIRTYCODE_API void NetConnTiming(uint8_t uEnableTiming);
|
||||
|
||||
typedef void (UserInfoCallbackT)(NetConnUserDataT *pUserDataT, void *pData);
|
||||
|
||||
// get the unique machine id
|
||||
DIRTYCODE_API uint32_t NetConnMachineId(void);
|
||||
|
||||
// set the unique machine id
|
||||
DIRTYCODE_API void NetConnSetMachineId(uint32_t uMachineId);
|
||||
|
||||
#if DIRTYCODE_LOGGING
|
||||
DIRTYCODE_API void NetConnMonitorValue(const char* pName, int32_t iValue);
|
||||
#endif
|
||||
|
||||
// copy a startup parameter
|
||||
DIRTYCODE_API int32_t NetConnCopyParam(char *pDst, int32_t iDstLen, const char *pParamName, const char *pSrc, const char *pDefault);
|
||||
|
||||
// create dirtycert module
|
||||
DIRTYCODE_API int32_t NetConnDirtyCertCreate(const char *pParams);
|
||||
|
||||
// translate netconn environment to string
|
||||
DIRTYCODE_API const char *NetConnGetEnvStr(void);
|
||||
|
||||
#if defined(DIRTYCODE_PS4)
|
||||
DIRTYCODE_API void NetConnRegisterNpStateCallback(NetConnNpStateCallbackT *pCallback, void *pUserData);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
// forward declare IEAUser so as not to create a dependency
|
||||
namespace EA { namespace User { class IEAUser; } }
|
||||
|
||||
// use this function to tell netconn about a newly detected local user on the local console
|
||||
DIRTYCODE_API int32_t NetConnAddLocalUser(int32_t iLocalUserIndex, const EA::User::IEAUser *pLocalUser);
|
||||
|
||||
// use this function to tell netconn about a removed local user on the local console
|
||||
// in cases where the index is unknown, pass -1 and we will do an internal query
|
||||
DIRTYCODE_API int32_t NetConnRemoveLocalUser(int32_t iLocalUserIndex, const EA::User::IEAUser *pLocalUser);
|
||||
#endif // __cplusplus
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netconn_h
|
||||
|
75
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/netconndefs.h
vendored
Normal file
75
src/thirdparty/dirtysdk/include/DirtySDK/dirtysock/netconndefs.h
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File netconndefs.h
|
||||
|
||||
\Description
|
||||
Definitions for the netconn module.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005-2009 Electronic Arts Inc.
|
||||
|
||||
\Version 09/29/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _netconndefs_h
|
||||
#define _netconndefs_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetConnDefs NetConnDefs
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// interface types, returned by NetConnStatus('type')
|
||||
#define NETCONN_IFTYPE_NONE (1) //!< indeterminate interface type
|
||||
#define NETCONN_IFTYPE_MODEM (2) //!< interface is a modem
|
||||
#define NETCONN_IFTYPE_ETHER (4) //!< interface is ethernet
|
||||
#define NETCONN_IFTYPE_USB (8) //!< interface bus type is USB
|
||||
#define NETCONN_IFTYPE_PPPOE (16) //!< interface is PPPoE
|
||||
#define NETCONN_IFTYPE_WIRELESS (32) //!< interface is wireless (wifi)
|
||||
#define NETCONN_IFTYPE_CELL (64) //!< interface is cellular
|
||||
|
||||
// EA back-end environment types, returned by NetConnStatus('envi')
|
||||
#define NETCONN_PLATENV_DEV (8) //!< Dev environment - Note (0) is used by the 'envi' NetConnStatus selector to indicate ~inp/try again
|
||||
#define NETCONN_PLATENV_TEST (1) //!< Test environment
|
||||
#define NETCONN_PLATENV_CERT (2) //!< Certification environment
|
||||
#define NETCONN_PLATENV_PROD (4) //!< Production environment
|
||||
|
||||
// generic netconn error responses
|
||||
#define NETCONN_ERROR_ISACTIVE (-1) //!< the module is currently active
|
||||
#define NETCONN_ERROR_NOTACTIVE (-2) //!< the module isn't currently active
|
||||
|
||||
|
||||
// generic NetConnStartup errors
|
||||
#define NETCONN_ERROR_NO_MEMORY (-2)
|
||||
#define NETCONN_ERROR_SOCKET_CREATE (-3)
|
||||
#define NETCONN_ERROR_DIRTYCERT_CREATE (-4)
|
||||
#define NETCONN_ERROR_PROTOSSL_CREATE (-5)
|
||||
#define NETCONN_ERROR_PROTOUPNP_CREATE (-6)
|
||||
#define NETCONN_ERROR_INTERNAL (-7)
|
||||
#define NETCONN_ERROR_PLATFORM_SPECIFIC (-8)
|
||||
#define NETCONN_ERROR_ALREADY_STARTED (-9)
|
||||
#define NETCONN_ERROR_RETRY (-10)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! network configuration entry
|
||||
typedef void * NetConfigRecT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netconndefs_h
|
||||
|
52
src/thirdparty/dirtysdk/include/DirtySDK/dirtyvers.h
vendored
Normal file
52
src/thirdparty/dirtysdk/include/DirtySDK/dirtyvers.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtyvers.h
|
||||
|
||||
\Description
|
||||
DirtySock SDK version.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2003-2005 Electronic Arts
|
||||
|
||||
\Version 06/13/2003 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtyvers_h
|
||||
#define _dirtyvers_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyVers DirtyVers
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define DIRTYSDK_VERSION_MAKE(year, season, major, minor, patch) (((year) * 100000000) + ((season) * 1000000) + ((major) * 10000) + ((minor) * 100) + (patch))
|
||||
|
||||
#define DIRTYSDK_VERSION_YEAR (15)
|
||||
#define DIRTYSDK_VERSION_SEASON (1)
|
||||
#define DIRTYSDK_VERSION_MAJOR (6)
|
||||
#define DIRTYSDK_VERSION_MINOR (0)
|
||||
#define DIRTYSDK_VERSION_PATCH (5)
|
||||
#define DIRTYSDK_VERSION (DIRTYSDK_VERSION_MAKE(DIRTYSDK_VERSION_YEAR, DIRTYSDK_VERSION_SEASON, DIRTYSDK_VERSION_MAJOR, DIRTYSDK_VERSION_MINOR, DIRTYSDK_VERSION_PATCH))
|
||||
#define DIRTYVERS (DIRTYSDK_VERSION)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtyvers_h
|
||||
|
266
src/thirdparty/dirtysdk/include/DirtySDK/game/connapi.h
vendored
Normal file
266
src/thirdparty/dirtysdk/include/DirtySDK/game/connapi.h
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File connapi.h
|
||||
|
||||
\Description
|
||||
ConnApi is a high-level connection manager, that packages the "connect to
|
||||
peer" process into a single module. Both game connections and voice
|
||||
connections can be managed. Multiple peers are supported in a host/client
|
||||
model for the game connection, and a peer/peer model for the voice
|
||||
connections.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2005. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 01/04/2005 (jbrookes) first version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _connapi_h
|
||||
#define _connapi_h
|
||||
|
||||
/*!
|
||||
\Moduledef ConnApi ConnApi
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyaddr.h"
|
||||
#include "DirtySDK/game/netgameutil.h"
|
||||
#include "DirtySDK/game/netgamelink.h"
|
||||
#include "DirtySDK/game/netgamedist.h"
|
||||
#include "DirtySDK/comm/commudp.h"
|
||||
#include "DirtySDK/dirtysock/netconn.h"
|
||||
#include "DirtySDK/proto/prototunnel.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
|
||||
// connection flags
|
||||
#define CONNAPI_CONNFLAG_GAMECONN (1) //!< game connection supported
|
||||
#define CONNAPI_CONNFLAG_VOIPCONN (2) //!< voip connection supported
|
||||
#define CONNAPI_CONNFLAG_GAMEVOIP (3) //!< game and voip connections supported
|
||||
|
||||
// connection status flags
|
||||
#define CONNAPI_CONNFLAG_CONNECTED (4) //!< set if connection succeeded
|
||||
#define CONNAPI_CONNFLAG_DEMANGLED (16) //!< set if demangler was attempted
|
||||
#define CONNAPI_CONNFLAG_PKTRECEIVED (32) //!< set if packets are received (for game connection only)
|
||||
|
||||
// error codes
|
||||
#define CONNAPI_ERROR_INVALID_STATE (-1) //!< connapi is in an invalid state
|
||||
#define CONNAPI_ERROR_CLIENTLIST_FULL (-2) //!< client list is full
|
||||
#define CONNAPI_ERROR_SLOT_USED (-3) //!< selected slot already in use
|
||||
#define CONNAPI_ERROR_SLOT_OUT_OF_RANGE (-4) //!< selected slot is not an valid index into the client array
|
||||
#define CONNAPI_CALLBACKS_FULL (-5) //!< maximum number of callbacks registered
|
||||
#define CONNAPI_CALLBACK_NOT_FOUND (-6) //!< callback not found
|
||||
|
||||
// supported connection concierge mode (to be used with 'ccmd' control selector)
|
||||
#define CONNAPI_CCMODE_PEERONLY (0) //!< peer connections only
|
||||
#define CONNAPI_CCMODE_HOSTEDONLY (1) //!< ccs connections only
|
||||
#define CONNAPI_CCMODE_HOSTEDFALLBACK (2) //!< peer connections fallback to ccs on failure
|
||||
|
||||
//! ConnApi callback types
|
||||
typedef enum ConnApiCbTypeE
|
||||
{
|
||||
CONNAPI_CBTYPE_GAMEEVENT, //!< a game event occurred
|
||||
CONNAPI_CBTYPE_DESTEVENT, //!< link/util ref destruction event
|
||||
CONNAPI_CBTYPE_VOIPEVENT, //!< a voip event occurred
|
||||
CONNAPI_NUMCBTYPES //!< number of callback types
|
||||
} ConnApiCbTypeE;
|
||||
|
||||
//! connection status
|
||||
typedef enum ConnApiConnStatusE
|
||||
{
|
||||
CONNAPI_STATUS_INIT, //!< initialization state
|
||||
CONNAPI_STATUS_CONN, //!< connecting to peer
|
||||
CONNAPI_STATUS_MNGL, //!< demangling
|
||||
CONNAPI_STATUS_ACTV, //!< connection established
|
||||
CONNAPI_STATUS_DISC, //!< disconnected
|
||||
CONNAPI_NUMSTATUSTYPES //!< max number of status types
|
||||
} ConnApiConnStatusE;
|
||||
|
||||
//! game topology types
|
||||
typedef enum ConnApiGameTopologyE
|
||||
{
|
||||
CONNAPI_GAMETOPOLOGY_DISABLED, //!< no game traffic
|
||||
CONNAPI_GAMETOPOLOGY_PEERWEB, //!< peer to peer full mesh
|
||||
CONNAPI_GAMETOPOLOGY_PEERHOSTED, //!< hosted by peer
|
||||
CONNAPI_GAMETOPOLOGY_SERVERHOSTED //!< hosted by server
|
||||
} ConnApiGameTopologyE;
|
||||
|
||||
//! voip topology types
|
||||
typedef enum ConnApiVoipTopologyE
|
||||
{
|
||||
CONNAPI_VOIPTOPOLOGY_DISABLED, //!< no voip traffic
|
||||
CONNAPI_VOIPTOPOLOGY_PEERWEB, //!< peer to peer full mesh
|
||||
CONNAPI_VOIPTOPOLOGY_SERVERHOSTED //!< peer to peer routed via server
|
||||
} ConnApiVoipTopologyE;
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
//! connection timers
|
||||
typedef struct ConnApiConnTimersT
|
||||
{
|
||||
uint32_t uCreateSATime; //!< time it takes to resolve secure association (xbox one)
|
||||
uint32_t uConnectTime; //!< time it takes for intial connection attempt
|
||||
uint32_t uDemangleTime; //!< time it takes to attempt demangling on the connection
|
||||
uint32_t uDemangleConnectTime; //!< time it takes to attempt a connection after demangling
|
||||
} ConnApiConnTimersT;
|
||||
|
||||
//! connection info
|
||||
typedef struct ConnApiConnInfoT
|
||||
{
|
||||
uint16_t uLocalPort; //!< local (bind) port
|
||||
uint16_t uMnglPort; //!< demangled port, if any
|
||||
uint8_t bDemangling; //!< is demangling process ongoing? (internal use only - see notes in connapi.c file header)
|
||||
uint8_t uConnFlags; //!< connection status flags (CONNAPI_CONNSTAT_*)
|
||||
uint8_t _pad[2];
|
||||
ConnApiConnStatusE eStatus; //!< status of connection (CONNAPI_STATUS_*)
|
||||
uint32_t iConnStart; //!< NetTick() recorded at connection or demangling start (internal use only)
|
||||
ConnApiConnTimersT ConnTimers; //!< connection timers
|
||||
} ConnApiConnInfoT;
|
||||
|
||||
//! client info
|
||||
typedef struct ConnApiClientInfoT
|
||||
{
|
||||
uint32_t uId; //!< unique connapi client id, uId should never be 0. A client with uId of 0 will be consider invalid.
|
||||
uint32_t uAddr; //!< external internet address of user
|
||||
uint8_t bIsConnectivityHosted; //!< flag for whether the connectivity to this client is direct or server-hosted
|
||||
uint32_t uRemoteClientId; //!< remote client id (used when setting up tunnel, game connection and voip connection with this client)
|
||||
uint32_t uLocalClientId; //!< local client id (used when setting up tunnel, game connection and voip connection with this client)
|
||||
uint32_t uHostingServerId; //!< id of the hosting server or 0 if none
|
||||
uint32_t uLocalAddr; //!< internal address of user
|
||||
uint16_t uGamePort; //!< external (send) port to use for game connection, or zero to use global port
|
||||
uint16_t uVoipPort; //!< external (send) port to use for voip connection, or zero to use global port
|
||||
uint16_t uLocalGamePort; //!< local (bind) port to use for game connection, or zero to use global port
|
||||
uint16_t uLocalVoipPort; //!< local (bind) port to use for voip connection, or zero to use global port
|
||||
uint16_t uTunnelPort; //!< user's tunnel port, or zero to use default
|
||||
uint16_t uLocalTunnelPort; //!< user's local tunnel port
|
||||
uint8_t bEnableQos; //!< enable QoS for this client, call ConnApiControl() with 'sqos' and 'lqos' to configure QoS settings
|
||||
uint8_t _pad[3];
|
||||
DirtyAddrT DirtyAddr; //!< dirtyaddr address of client
|
||||
char strTunnelKey[PROTOTUNNEL_MAXKEYLEN]; //!< tunnel key
|
||||
} ConnApiClientInfoT;
|
||||
|
||||
//! connection type
|
||||
typedef struct ConnApiClientT
|
||||
{
|
||||
ConnApiClientInfoT ClientInfo;
|
||||
ConnApiConnInfoT GameInfo; //!< info about game connection
|
||||
ConnApiConnInfoT VoipInfo; //!< info about voip connection
|
||||
NetGameUtilRefT *pGameUtilRef; //!< util ref for connection
|
||||
NetGameLinkRefT *pGameLinkRef; //!< link ref for connection
|
||||
NetGameDistRefT *pGameDistRef; //!< dist ref for connection (for app use; not managed by ConnApi)
|
||||
int32_t iTunnelId; //!< tunnel identifier (if any)
|
||||
uint16_t uConnFlags; //!< CONNAPI_CONNFLAG_* describing the connection type (read-only)
|
||||
int16_t iVoipConnId; //!< voip connection identifier
|
||||
uint16_t uFlags; //!< internal client flags
|
||||
uint8_t bAllocated; //!< TRUE if this slot is allocated, else FALSE
|
||||
uint8_t bEstablishVoip; //!< used to establish voip when enable QoS is set (after QoS has been validated), call ConnApiControl() with 'estv' to configure
|
||||
} ConnApiClientT;
|
||||
|
||||
//! connection list type
|
||||
typedef struct ConnApiClientListT
|
||||
{
|
||||
int32_t iNumClients; //!< number of clients in list
|
||||
int32_t iMaxClients; //!< max number of clients
|
||||
ConnApiClientT Clients[1]; //!< client array (variable length)
|
||||
} ConnApiClientListT;
|
||||
|
||||
//! callback info
|
||||
typedef struct ConnApiCbInfoT
|
||||
{
|
||||
int32_t iClientIndex; //!< index of client event is for
|
||||
uint32_t eType; //!< type of event (CONNAPI_CBTYPE_*)
|
||||
uint32_t eOldStatus; //!< old status (CONNAPI_STATUS_*)
|
||||
uint32_t eNewStatus; //!< new status (CONNAPI_STATUS_*)
|
||||
const ConnApiClientT* pClient; //!< pointer to the corresponding client structure
|
||||
} ConnApiCbInfoT;
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ConnApiRefT ConnApiRefT;
|
||||
|
||||
/*!
|
||||
\Callback ConnApiCallbackT
|
||||
|
||||
\Description
|
||||
Callback fired when a connection event happens identified by the information
|
||||
in pCbInfo
|
||||
|
||||
\Input *pConnApi - module state
|
||||
\Input *pCbInfo - callback information
|
||||
\Input *pUserData - user information passed along with the callback
|
||||
*/
|
||||
typedef void (ConnApiCallbackT)(ConnApiRefT *pConnApi, ConnApiCbInfoT *pCbInfo, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! create the module state
|
||||
#define ConnApiCreate(_iGamePort, _iMaxClients, _pCallback, _pUserData) ConnApiCreate2(_iGamePort, _iMaxClients, _pCallback, _pUserData, (CommAllConstructT *)CommUDPConstruct)
|
||||
|
||||
// create the module state
|
||||
DIRTYCODE_API ConnApiRefT *ConnApiCreate2(int32_t iGamePort, int32_t iMaxClients, ConnApiCallbackT *pCallback, void *pUserData, CommAllConstructT *pConstruct);
|
||||
|
||||
// this function should be called once the user has logged on and the input parameters are available
|
||||
DIRTYCODE_API void ConnApiOnline(ConnApiRefT *pConnApi, const char *pGameName, uint32_t uSelfId, ConnApiGameTopologyE eGameTopology, ConnApiVoipTopologyE eVoipTopology);
|
||||
|
||||
// destroy the module state
|
||||
DIRTYCODE_API void ConnApiDestroy(ConnApiRefT *pConnApi);
|
||||
|
||||
// host or connect to a game / voip, with the possibility to import connection.
|
||||
DIRTYCODE_API void ConnApiConnect(ConnApiRefT *pConnApi, ConnApiClientInfoT *pClientList, int32_t iClientListSize, int32_t iGameHostIndex, int32_t iVoipHostIndex, int32_t iSessId);
|
||||
|
||||
// add a new client to a pre-existing game in the specified index.
|
||||
DIRTYCODE_API int32_t ConnApiAddClient(ConnApiRefT *pConnApi, ConnApiClientInfoT *pClientInfo, int32_t iClientIdx);
|
||||
|
||||
// return the ConnApiClientT for the specified client (by id)
|
||||
DIRTYCODE_API uint8_t ConnApiFindClient(ConnApiRefT *pConnApi, ConnApiClientInfoT *pClientInfo, ConnApiClientT *pOutClient);
|
||||
|
||||
// remove a current client from a game
|
||||
DIRTYCODE_API void ConnApiRemoveClient(ConnApiRefT *pConnApi, int32_t iClientIdx);
|
||||
|
||||
// redo all connections, using the host specified
|
||||
DIRTYCODE_API void ConnApiMigrateGameHost(ConnApiRefT *pConnApi, int32_t iNewGameHostIndex);
|
||||
|
||||
// disconnect from game
|
||||
DIRTYCODE_API void ConnApiDisconnect(ConnApiRefT *pConnApi);
|
||||
|
||||
// get list of current connections
|
||||
DIRTYCODE_API const ConnApiClientListT *ConnApiGetClientList(ConnApiRefT *pConnApi);
|
||||
|
||||
// connapi status
|
||||
DIRTYCODE_API int32_t ConnApiStatus(ConnApiRefT *pConnApi, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// connapi status (version 2)
|
||||
DIRTYCODE_API int32_t ConnApiStatus2(ConnApiRefT *pConnApi, int32_t iSelect, void *pData, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// connapi control
|
||||
DIRTYCODE_API int32_t ConnApiControl(ConnApiRefT *pConnApi, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// update connapi module (must be called directly if auto-update is disabled)
|
||||
DIRTYCODE_API void ConnApiUpdate(ConnApiRefT *pConnApi);
|
||||
|
||||
// Register a new callback
|
||||
DIRTYCODE_API int32_t ConnApiAddCallback(ConnApiRefT *pConnApi, ConnApiCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// Removes a callback previously registered
|
||||
DIRTYCODE_API int32_t ConnApiRemoveCallback(ConnApiRefT *pConnApi, ConnApiCallbackT *pCallback, void *pUserData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _connapi_h
|
||||
|
177
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamedist.h
vendored
Normal file
177
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamedist.h
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File netgamedist.h
|
||||
|
||||
\Description
|
||||
The GameDist class provides the main control interface between the
|
||||
individual game controllers and the distributed game-input engine.
|
||||
The GameInput and GameComm classes provided the interfaces used by
|
||||
this class for real-world communication.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 1998-2007.
|
||||
|
||||
\Version 1.0 12/15/1998 (gschaefer) First Version
|
||||
\Version 1.1 12/26/1999 (gschaefer) Revised to add external stats interface
|
||||
\Version 1.2 11/18/2002 (jbrookes) Moved to NetGame hierarchy
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _netgamedist_h
|
||||
#define _netgamedist_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGameDist NetGameDist
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/game/netgameerr.h"
|
||||
#include "DirtySDK/game/netgamepkt.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define GMDIST_DEFAULT_BUFFERSIZE_IN (16384) //<! default queue size for outbound packets
|
||||
#define GMDIST_DEFAULT_BUFFERSIZE_OUT (8192) //<! default queue size for inbound packets
|
||||
|
||||
#define GMDIST_MAX_CLIENTS (32) //<! maximum number of clients
|
||||
#define GMDIST_ERROR_SIZE (2048) //<! max string size for NetGameDistGetErrorText
|
||||
|
||||
#define GMDIST_DATA_NONE (1) //<! packets type: Nothing
|
||||
#define GMDIST_DATA_INPUT (2) //<! Input from some player
|
||||
#define GMDIST_DATA_INPUT_DROPPABLE (3) //<! Droppable input from some player
|
||||
#define GMDIST_DATA_DISCONNECT (4) //<! Disconnected player
|
||||
#define GMDIST_DATA_NODATA (5) //<! Sparse multipacket with blank for this player
|
||||
|
||||
// This value end up being packed in a nibble. The fourth bit is reserved:
|
||||
#define GMDIST_DATA_CRC_REQUEST (0x08) //<! CRC check challenge from the GS
|
||||
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
//! calculates positive modulo
|
||||
#define GMDIST_Modulo(iDividend, iDivisor) ((((iDividend) % (iDivisor)) + (iDivisor)) % (iDivisor))
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
// opaque module ref
|
||||
typedef struct NetGameDistRefT NetGameDistRefT;
|
||||
|
||||
//! dist stat proc
|
||||
typedef int32_t (NetGameDistStatProc)(void *pLinkRef, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize);
|
||||
|
||||
//! dist send proc
|
||||
typedef int32_t (NetGameDistSendProc)(void *pLinkRef, NetGamePacketT *pPkt, int32_t iLen);
|
||||
|
||||
//! dist recv proc
|
||||
typedef int32_t (NetGameDistRecvProc)(void *pLinkRef, NetGamePacketT *pPkt, int32_t iLen, uint8_t bDist);
|
||||
|
||||
//! dist peek proc
|
||||
typedef int32_t (NetGameDistPeekProc)(void *pLinkRef, NetGamePacketT **pPkt, uint32_t uMask);
|
||||
|
||||
//! dist drop proc
|
||||
typedef int8_t (NetGameDistDropProc)(void *pLinkRef, void *pExisting, void *pIncoming, uint8_t uTypeExisting, uint8_t uTypeIncoming);
|
||||
|
||||
typedef int32_t (NetGameDistLinkCtrlProc)(void *ref, int32_t iKind, int32_t iData);
|
||||
|
||||
typedef struct NetGameDistStatT
|
||||
{
|
||||
uint16_t late; //!< overall latency of game (show this to user)
|
||||
uint16_t bps; //!< bytes per second (user data)
|
||||
uint8_t pps; //!< packets per second (user packets)
|
||||
uint8_t slen; //!< comm send queue length
|
||||
uint8_t plost; //!< remote->local packets lost: number of packets (from peer) lost
|
||||
uint8_t naksent; //!< number of NAKs received by peer (from us)
|
||||
} NetGameDistStatT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct the game client
|
||||
DIRTYCODE_API NetGameDistRefT *NetGameDistCreate(void *pLinkRef, NetGameDistStatProc *pStatProc, NetGameDistSendProc *pSendProc, NetGameDistRecvProc *pRecvProc, uint32_t uInBufferSize, uint32_t uOutBufferSize );
|
||||
|
||||
// destruct the game client
|
||||
DIRTYCODE_API void NetGameDistDestroy(NetGameDistRefT *pRef);
|
||||
|
||||
// status function
|
||||
DIRTYCODE_API int32_t NetGameDistStatus(NetGameDistRefT *pRef, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// for game-server usage, make NetGameDist send multi-packet
|
||||
DIRTYCODE_API void NetGameDistSetServer(NetGameDistRefT *pRef, uint8_t bActAsServer);
|
||||
|
||||
// on the server: iDist index will be the index of the player that owns the dist
|
||||
// on the client: iDist index will be the index of the local player that owns the dist
|
||||
// iTotplayers will always be the total players in game
|
||||
DIRTYCODE_API void NetGameDistMultiSetup(NetGameDistRefT *pRef, int32_t iDistIndex, int32_t iTotPlrs );
|
||||
|
||||
// set whether to enable meta-information sending, the mask and the version number
|
||||
DIRTYCODE_API void NetGameDistMetaSetup(NetGameDistRefT *pRef, uint8_t bSparse, uint32_t uMask, uint32_t uVersion);
|
||||
|
||||
// peek input from peer
|
||||
DIRTYCODE_API int32_t NetGameDistInputPeek(NetGameDistRefT *pRef, uint8_t *pType, void *pPeer, int32_t *pPlen);
|
||||
|
||||
// return completed input from client
|
||||
DIRTYCODE_API int32_t NetGameDistInputQuery(NetGameDistRefT *pRef, void *pOurs, int32_t *pOlen, void *pPeer, int32_t *pPlen);
|
||||
|
||||
// return completed input from multiple clients
|
||||
DIRTYCODE_API int32_t NetGameDistInputQueryMulti(NetGameDistRefT *pRef, uint8_t *pDataTypes, void **pInputs, int32_t *pLen);
|
||||
|
||||
// provide local input data
|
||||
DIRTYCODE_API int32_t NetGameDistInputLocal(NetGameDistRefT *pRef, void *pBuffer, int32_t iLen);
|
||||
|
||||
// provide local input data (n-consoles). Client usage is to provide one-long arrays. Type can be GMDIST_DATA_INPUT, GMDIST_DATA_INPUT_DROPPABLE
|
||||
DIRTYCODE_API int32_t NetGameDistInputLocalMulti(NetGameDistRefT *pRef, uint8_t *pTypesArray, void **ppBuffer, int32_t *pLengthsArray, int32_t iDelta);
|
||||
|
||||
// check input status (see how long till next)
|
||||
DIRTYCODE_API void NetGameDistInputCheck(NetGameDistRefT *pRef, int32_t *pSend, int32_t *pRecv);
|
||||
|
||||
// set new input exchange rate
|
||||
DIRTYCODE_API void NetGameDistInputRate(NetGameDistRefT *pRef, int32_t iRate);
|
||||
|
||||
// flush the input queue (note that this must be done with
|
||||
DIRTYCODE_API void NetGameDistInputClear(NetGameDistRefT *pRef);
|
||||
|
||||
// set NetGameDist operation parameters
|
||||
DIRTYCODE_API int32_t NetGameDistControl(NetGameDistRefT *pRef, int32_t iSelect, int32_t iValue, void *pValue);
|
||||
|
||||
// dispatch to appropriate updaters
|
||||
DIRTYCODE_API uint32_t NetGameDistUpdate(NetGameDistRefT *pRef);
|
||||
|
||||
// override the send,recv,stats procs or set the drop proc
|
||||
DIRTYCODE_API void NetGameDistSetProc(NetGameDistRefT *pRef, int32_t iKind, void *pProc);
|
||||
|
||||
// For the game server to provides stats, the array must be sized according to what was passed to NetGameDistMultiSetup
|
||||
DIRTYCODE_API void NetGameDistSendStats(NetGameDistRefT *pRef, NetGameDistStatT *pStats);
|
||||
|
||||
// return non-zero if there ever was an overflow
|
||||
DIRTYCODE_API int32_t NetGameDistGetError(NetGameDistRefT *pRef);
|
||||
|
||||
// copies into the passed buffer the last error text.
|
||||
DIRTYCODE_API void NetGameDistGetErrorText(NetGameDistRefT *pRef, char *pErrorBuffer, int32_t iBufSize);
|
||||
|
||||
// reset the error count
|
||||
DIRTYCODE_API void NetGameDistResetError(NetGameDistRefT *pRef);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgamedist_h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
97
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamedistserv.h
vendored
Normal file
97
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamedistserv.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File netgamedistserv.h
|
||||
|
||||
\Description
|
||||
Server module to handle 2+ NetGameDist connections in a client/server
|
||||
architecture.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2007 Electronic Arts
|
||||
|
||||
\Version 02/01/2007 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _netgamedistserv_h
|
||||
#define _netgamedistserv_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGameDistServ NetGameDistServ
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/game/netgamelink.h"
|
||||
#include "DirtySDK/game/netgamedist.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module state
|
||||
typedef struct NetGameDistServT NetGameDistServT;
|
||||
|
||||
//! logging function type
|
||||
typedef int32_t (NetGameDistServLoggingCbT)(const char *pText, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module state
|
||||
DIRTYCODE_API NetGameDistServT *NetGameDistServCreate(int32_t iMaxClients, int32_t iVerbosity);
|
||||
|
||||
// destroy the module state
|
||||
DIRTYCODE_API void NetGameDistServDestroy(NetGameDistServT *pDistServ);
|
||||
|
||||
// add a client to module
|
||||
DIRTYCODE_API int32_t NetGameDistServAddClient(NetGameDistServT *pDistServ, int32_t iClient, NetGameLinkRefT *pLinkRef, const char *pClientName);
|
||||
|
||||
// del a client from module
|
||||
DIRTYCODE_API int32_t NetGameDistServDelClient(NetGameDistServT *pDistServ, int32_t iClient);
|
||||
|
||||
// notify that a client disconnected
|
||||
DIRTYCODE_API int32_t NetGameDistServDiscClient(NetGameDistServT *pDistServ, int32_t iClient);
|
||||
|
||||
// update a client
|
||||
DIRTYCODE_API int32_t NetGameDistServUpdateClient(NetGameDistServT *pDistServ, int32_t iClient);
|
||||
|
||||
// update the module (must be called at fixed rate)
|
||||
DIRTYCODE_API void NetGameDistServUpdate(NetGameDistServT *pDistServ);
|
||||
|
||||
// whether the highwater mark changed, and the current highwater values.
|
||||
DIRTYCODE_API uint8_t NetGameDistServHighWaterChanged(NetGameDistServT *pDistServ, int32_t* pHighWaterInputQueue, int32_t* pHighWaterOutputQueue);
|
||||
|
||||
// return the lastest error reported by netgamedist, for client iClient
|
||||
DIRTYCODE_API char* NetGameDistServExplainError(NetGameDistServT *pDistServ, int32_t iClient);
|
||||
|
||||
// netgamedistserv control
|
||||
DIRTYCODE_API int32_t NetGameDistServControl(NetGameDistServT *pDistServ, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// netgamedistserv status
|
||||
DIRTYCODE_API int32_t NetGameDistServStatus(NetGameDistServT *pDistServ, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// netgamedistserv2 status
|
||||
DIRTYCODE_API int32_t NetGameDistServStatus2(NetGameDistServT *pDistServ, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// set logging callback
|
||||
DIRTYCODE_API void NetGameDistServSetLoggingCallback(NetGameDistServT *pDistServ, NetGameDistServLoggingCbT *pLoggingCb, void *pUserData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgamedistserv_h
|
||||
|
67
src/thirdparty/dirtysdk/include/DirtySDK/game/netgameerr.h
vendored
Normal file
67
src/thirdparty/dirtysdk/include/DirtySDK/game/netgameerr.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File netgameerr.h
|
||||
|
||||
\Description
|
||||
Error codes for GameDist functions (errors always negative)
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 1998-2007
|
||||
|
||||
\Version 1.0 23/06/2009 (jrainy) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _netgameerr_h
|
||||
#define _netgameerr_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGameErr NetGameErr
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define GMDIST_ORPHAN (-1) //<! error - orphan
|
||||
#define GMDIST_OVERFLOW (-2) //<! error - overflow
|
||||
#define GMDIST_INVALID (-3) //<! error - invalid
|
||||
#define GMDIST_BADSETUP (-4) //<! error - badly setup number of players and/or index
|
||||
#define GMDIST_SENDPROC_FAILED (-5) //<! error condition - SendProc failed
|
||||
#define GMDIST_QUEUE_FULL (-6) //<! error condition - too many queued packets
|
||||
#define GMDIST_QUEUE_MEMORY (-7) //<! error condition - queue has insufficient space left
|
||||
#define GMDIST_STREAM_FAILURE (-8) //<! error - stream failed
|
||||
#define GMDIST_NO_STREAM (-9) //<! error - stream failed (no ref)
|
||||
#define GMDIST_DELETED (-10) //<! error - deleted
|
||||
#define GMDIST_PEEK_ERROR (-11) //<! error peek
|
||||
#define GMDIST_INPUTLOCAL_FAILED (-12) //<! error inputlocal
|
||||
#define GMDIST_INPUTQUERY_FAILED (-13) //<! error inputquery
|
||||
#define GMDIST_DISCONNECTED (-14) //<! error disconnected
|
||||
#define GMDIST_INPUTLOCAL_FAILED_INVALID (-15) //<! error inputlocal with invalid.
|
||||
#define GMDIST_INPUTLOCAL_FAILED_MULTI (-16) //<! error inputlocal with invalid.
|
||||
#define GMDIST_INPUTLOCAL_FAILED_WINDOW (-17) //<! error inputlocal with invalid.
|
||||
#define GMDIST_OVERFLOW_MULTI (-18) //<! error - overflow
|
||||
#define GMDIST_OVERFLOW_WINDOW (-19) //<! error - overflow
|
||||
#define GMDIST_DESYNCED (-20) //<! error - desynced
|
||||
#define GMDIST_DESYNCED_ALL_PLAYERS (-21) //<! error - desynced all players
|
||||
|
||||
#define GMLINK_DIRTYCAST_DELETED (-64) //<! error - GameServer had the link deleted
|
||||
#define GMLINK_DIRTYCAST_CONNECTION_TIMEDOUT (-65) //<! error - GameServer connection timed out
|
||||
#define GMLINK_DIRTYCAST_CONNECTION_FAILURE (-66) //<! error - GameServer initial connection failed
|
||||
#define GMLINK_DIRTYCAST_PEER_DISCONNECT (-67) //<! error - GameServer peer diconnected
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgameerr_h
|
221
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamelink.h
vendored
Normal file
221
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamelink.h
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File netgamelink.h
|
||||
|
||||
\Description
|
||||
The GameLink class provides the main control interface between the
|
||||
individual game controllers and the distributed game-input engine.
|
||||
The GameInput and GameComm classes provided the interfaces used by
|
||||
this class for real-world communication.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 1998-2002
|
||||
|
||||
\Version 1.0 12/15/1998 (gschaefer) First Version
|
||||
\Version 1.1 12/26/1999 (gschaefer) Revised to add external stats interface
|
||||
\Version 1.2 11/18/2002 (jbrookes) Moved to NetGame hierarchy
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _netgamelink_h
|
||||
#define _netgamelink_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGameLink NetGameLink
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/game/netgamepkt.h"
|
||||
#include "DirtySDK/game/netgameerr.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define PING_HISTORY 32 //!< must be a power of 2
|
||||
#define PING_LENGTH 250 //!< sample every 250 ms
|
||||
#define PING_DEFAULT 200 //!< default value if no sample available
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! opaque module state
|
||||
typedef struct NetGameLinkRefT NetGameLinkRefT;
|
||||
|
||||
//! structure providing access to ping history
|
||||
typedef struct NetGameLinkHistT
|
||||
{
|
||||
uint16_t min; //!< minimum ping value
|
||||
uint16_t max; //!< maximu ping value
|
||||
uint16_t avg; //!< average ping value
|
||||
uint16_t cnt; //!< number of samples
|
||||
} NetGameLinkHistT;
|
||||
|
||||
//! structure providing access to game/comm stats (in the past, had to be a multiple of 16 bytes to support IOP/EE DMA!)
|
||||
typedef struct NetGameLinkStatT
|
||||
{
|
||||
volatile uint32_t tick; //!< most recent tick (used for other tick calculations)
|
||||
volatile uint32_t tickseqn; //!< changed every time thread stuff updates the tick
|
||||
|
||||
uint32_t ping; //!< peer to peer ping
|
||||
uint32_t late; //!< overall latency of game (show this to user)
|
||||
uint32_t conn; //!< when connection established
|
||||
uint32_t sent; //!< number of bytes sent
|
||||
uint32_t rcvd; //!< number of bytes received
|
||||
uint32_t sentlast; //!< when data most recently sent
|
||||
uint32_t rcvdlast; //!< when data most recently received
|
||||
uint32_t sentshow; //!< show send-data indicator
|
||||
uint32_t rcvdshow; //!< show recv-data indicator
|
||||
uint32_t senthide; //!< hide send-data indicator (ignore -- use show)
|
||||
uint32_t rcvdhide; //!< hide recv-data indicator (ignore -- use recv)
|
||||
uint32_t outbps; //!< [outbound] bytes per second (user data)
|
||||
uint32_t outrps; //!< [outbound] raw bytes per second (data sent to network)
|
||||
uint32_t outnps; //!< [outbound] network bytes per second (rps + estimated UDP/Ethernet frame overhead)
|
||||
uint32_t outpps; //!< [outbound] packets per second (user packets)
|
||||
uint32_t outrpps; //!< [outbound] raw packets per second (packets sent to network)
|
||||
uint32_t inbps; //!< [inbound] received bytes per second
|
||||
uint32_t inrps; //!< [inbound] received raw bytes per second
|
||||
uint32_t innps; //!< [inbound] received network bytes per second
|
||||
uint32_t inpps; //!< [inbound] received packets per second
|
||||
uint32_t inrpps; //!< [inbound] received raw packets per second (rps + estimated UDP/Ethernet frame overhead)
|
||||
uint32_t stattick; //!< the tick at which period stats were updated
|
||||
uint32_t lnaksent; //!< number of NAKs received by peer (from us) since start
|
||||
uint32_t lpacksent; //!< number of packets sent to peer since start (at time = last inbound sync packet)
|
||||
uint32_t lpacksent_now; //!< number of packets sent to peer since start (at time = now)
|
||||
uint32_t lpackrcvd; //!< number of packets received from peer since start
|
||||
uint32_t lpacklost; //!< remote->local packets lost: number of packets (from peer) lost since start - not always equal to (rpacksent - lpackrcvd)
|
||||
uint32_t lpacksaved; //!< number of packets recovered by underlying commudp redundancy mechanism
|
||||
uint32_t rnaksent; //!< number of NAKs sent by peer (to us) since start
|
||||
uint32_t rpacksent; //!< number of packets sent by peer (to us) since start
|
||||
uint32_t rpackrcvd; //!< number of packets received by peer (from us) since start
|
||||
uint32_t rpacklost; //!< local->remote packets lost: number of packets (from us) lost by peer since start - not always equal to (lpacksent - rpackrcvd)
|
||||
/* Notes
|
||||
Attempting to calculate the number of local->remote packets lost with (lpacksent - rpackrcvd) sometimes
|
||||
lead to a boosted packet loss result because some in-flight packets are accounted in the sent counter but not
|
||||
in the rcved counter. For a precise local->remote packet loss value, rpacklost is better because
|
||||
it is obtained from the remote end directly (from the inbound NetGameLinkSyncT packet)
|
||||
|
||||
Attempting to calculate the number of remote->local packets lost with (rpacksent - lpackrcvd) sometimes
|
||||
lead to reduced (or even negative) packet loss result because additional inbound packets are
|
||||
received when commudp retransmission mechanisms quick in to guarantee transport reliability. Those
|
||||
packet are accounted for in the rcved counter but not in the sent counter. For a precise
|
||||
remote->local packet loss value, lpacklost is better because it takes the above phenomenon
|
||||
into account. */
|
||||
|
||||
uint8_t isconn; //!< listening or connecting \Deprecated
|
||||
uint8_t isopen; //!< listening, connecting, or connected
|
||||
uint8_t pad0[2]; //!< pad to four-byte alignment
|
||||
|
||||
uint32_t pingtick; //!< last tick at which ping stuff updated
|
||||
uint32_t pingslot; //!< the index containing the current ping
|
||||
int32_t pingdev; //!< ping deviation
|
||||
int32_t pingavg; //!< ping average
|
||||
|
||||
NetGameLinkHistT pinghist[PING_HISTORY];
|
||||
} NetGameLinkStatT;
|
||||
|
||||
// stream structure
|
||||
typedef struct NetGameLinkStreamT NetGameLinkStreamT;
|
||||
|
||||
//! dist stream send proc
|
||||
typedef int32_t (NetGameLinkStreamSendProc)(NetGameLinkStreamT *pStream, int32_t iSubchan, int32_t iKind, void *pBuffer, int32_t iLen);
|
||||
//! dist stream recv proc
|
||||
typedef void (NetGameLinkStreamRecvProc)(NetGameLinkStreamT *pStream, int32_t iSubchan, int32_t iKind, void *pBuffer, int32_t iLen);
|
||||
|
||||
typedef struct NetGameLinkStreamInpT
|
||||
{
|
||||
char *pInpData; //!< private
|
||||
int32_t iInpSize; //!< private
|
||||
int32_t iInpProg; //!< private
|
||||
int32_t iInpKind; //!< private
|
||||
} NetGameLinkStreamInpT;
|
||||
|
||||
//! structure to access network stream with
|
||||
struct NetGameLinkStreamT
|
||||
{
|
||||
NetGameLinkStreamT *pNext; //!< private
|
||||
NetGameLinkRefT *pClient; //!< private
|
||||
|
||||
int32_t iIdent; //!< private (can read -- stream identifier)
|
||||
int32_t iSubchan; //!< number of subchannels
|
||||
int32_t iRefNum; //!< public (for callers use)
|
||||
void *pRefPtr; //!< public (for callers use)
|
||||
NetGameLinkStreamSendProc *Send;//!< public
|
||||
NetGameLinkStreamRecvProc *Recv;//!< public
|
||||
int32_t iQueueDepth; //!< public read only (total bytes in output queue)
|
||||
int32_t iQueueLimit; //!< public read/write (maximum outgoing queue limit)
|
||||
|
||||
int32_t iHighWaterUsed; //!< public read only
|
||||
int32_t iHighWaterNeeded; //!< public read only
|
||||
|
||||
int32_t iInpMaxm; //!< private
|
||||
NetGameLinkStreamInpT *pInp; //!< private
|
||||
|
||||
char *pOutData; //!< private
|
||||
int32_t iOutMaxm; //!< private
|
||||
int32_t iOutSize; //!< private
|
||||
int32_t iOutProg; //!< private
|
||||
|
||||
char *pSynData; //!< private
|
||||
int32_t iSynMaxm; //!< private
|
||||
int32_t iSynSize; //!< private
|
||||
};
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct the game client
|
||||
DIRTYCODE_API NetGameLinkRefT *NetGameLinkCreate(void *pCommRef, int32_t iOwner, int32_t iBufLen);
|
||||
|
||||
// destruct the game client
|
||||
DIRTYCODE_API void NetGameLinkDestroy(NetGameLinkRefT *pRef);
|
||||
|
||||
// register a callback function
|
||||
DIRTYCODE_API void NetGameLinkCallback(NetGameLinkRefT *pRef, void *pCallData, void (*pCallProc)(void *pCallData, int32_t iKind));
|
||||
|
||||
// status function
|
||||
DIRTYCODE_API int32_t NetGameLinkStatus(NetGameLinkRefT *pRef, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// incoming packet stream from upper layer
|
||||
DIRTYCODE_API int32_t NetGameLinkSend(NetGameLinkRefT *pRef, NetGamePacketT *pPkt, int32_t iLen);
|
||||
|
||||
// peek into the buffer
|
||||
DIRTYCODE_API int32_t NetGameLinkPeek(NetGameLinkRefT *pRef, NetGamePacketT **ppPkt);
|
||||
|
||||
// peek into the buffer for specific packet types
|
||||
DIRTYCODE_API int32_t NetGameLinkPeek2(NetGameLinkRefT *pRef, NetGamePacketT **ppPkt, uint32_t uMask);
|
||||
|
||||
// outgoing packet stream to upper layer
|
||||
DIRTYCODE_API int32_t NetGameLinkRecv(NetGameLinkRefT *pRef, NetGamePacketT *pBuf, int32_t iLen, uint8_t bDist);
|
||||
|
||||
// same as NetGameLinkRecv, but takes a mask of which GAME_PACKET types we want
|
||||
DIRTYCODE_API int32_t NetGameLinkRecv2(NetGameLinkRefT *pRef, NetGamePacketT *pBuf, int32_t iLen, uint32_t uMask);
|
||||
|
||||
// control behavior
|
||||
DIRTYCODE_API int32_t NetGameLinkControl(NetGameLinkRefT *pRef, int32_t iSelect, int32_t iValue, void *pValue);
|
||||
|
||||
// dispatch to appropriate updaters
|
||||
DIRTYCODE_API uint32_t NetGameLinkUpdate(NetGameLinkRefT *pRef);
|
||||
|
||||
// create a new network stream
|
||||
DIRTYCODE_API NetGameLinkStreamT *NetGameLinkCreateStream(NetGameLinkRefT *pRef, int32_t iSubChan, int32_t iIdent, int32_t iInpLen, int32_t iOutLen, int32_t iSynLen);
|
||||
|
||||
// destroy an existing network stream
|
||||
DIRTYCODE_API void NetGameLinkDestroyStream(NetGameLinkRefT *pRef, NetGameLinkStreamT *pStream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgamelink_h
|
||||
|
159
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamepkt.h
vendored
Normal file
159
src/thirdparty/dirtysdk/include/DirtySDK/game/netgamepkt.h
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File netgamepkt.h
|
||||
|
||||
\Description
|
||||
Defines netgame packet constants and types.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 1998-2007.
|
||||
|
||||
\Version 1.0 12/12/1998 (gschaefer) First Version
|
||||
\Version 1.1 11/18/2002 (jbrookes) Moved to NetGame hierarchy
|
||||
\Version 1.2 02/04/2007 (jbrookes) Cleanup, added NetGameMaxPacketT
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _netgamepkt_h
|
||||
#define _netgamepkt_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGamePkt NetGamePkt
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/* sampling period constants
|
||||
dont enum these or you will regret it
|
||||
(the compiler translates divides by these into logical shifts) */
|
||||
#define RTT_SAMPLE_PERIOD 1024
|
||||
#define LATE_SAMPLE_PERIOD 512
|
||||
|
||||
//! identifiers of client/server packets
|
||||
enum
|
||||
{
|
||||
GAME_PACKET_ONE_BEFORE_FIRST =1,//!< enum with value 1 available for future use. If needed just lower ONE_BEFORE_FIRST to zero
|
||||
GAME_PACKET_INPUT, //!< data exchanged by machines using dist, usually controller inputs
|
||||
GAME_PACKET_INPUT_MULTI, //!< same as INPUT but from the game server.
|
||||
GAME_PACKET_STATS, //!< stats sent by the game server.
|
||||
GAME_PACKET_USER, //!< user packet
|
||||
GAME_PACKET_USER_UNRELIABLE, //!< user packet, to be sent unreliably
|
||||
GAME_PACKET_USER_BROADCAST, //!< user packet, to be sent unreliably to broadcast address
|
||||
GAME_PACKET_INPUT_FLOW, //!< dist flow control, sent to indicate readiness
|
||||
GAME_PACKET_INPUT_MULTI_FAT, //!< same as INPUT_MULTI but 16-bit individual packet sizes (to allow 256-1200 sizes).
|
||||
GAME_PACKET_INPUT_META, //!< meta-information on the packet format
|
||||
GAME_PACKET_LINK_STRM, //!< netgamelink stream packet
|
||||
GAME_PACKET_ONE_PAST_LAST, //!< used to mark the valid range. Insert new kinds before
|
||||
GAME_PACKET_SYNC = 64 //!< OR this value with packet kind to signal that packet conveys sync info
|
||||
};
|
||||
|
||||
//! default max raw data packet size
|
||||
#define NETGAME_DATAPKT_DEFSIZE (240)
|
||||
|
||||
//! max raw data packet size
|
||||
#define NETGAME_DATAPKT_MAXSIZE (1200)
|
||||
|
||||
//! max size of packet tail (sync+kind)
|
||||
#define NETGAME_DATAPKT_MAXTAIL (sizeof(NetGamePacketSyncT)+1)
|
||||
|
||||
//! max stream packet size
|
||||
#define NETGAME_STRMPKT_DEFSIZE (200)
|
||||
#define NETGAME_STRMPKT_MAXSIZE (NETGAME_DATAPKT_MAXSIZE - 12)
|
||||
|
||||
//! default max input/output buffers, in packets
|
||||
#define NETGAME_DATABUF_MAXSIZE (32)
|
||||
|
||||
// sync packet flags
|
||||
|
||||
//!< indicates repl field is not yet valid (remote side has not received our first sync packet yet)
|
||||
#define NETGAME_SYNCFLAG_REPLINVALID (0x01)
|
||||
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! packet header (common for every packet)
|
||||
typedef struct NetGamePacketHeadT
|
||||
{
|
||||
int32_t size; //!< total size (including header, 4-byte aligned)
|
||||
uint32_t when; //!< reception time in ticks
|
||||
uint16_t len; //!< length of packet body
|
||||
uint8_t kind; //!< packet type (see enum above)
|
||||
uint8_t pad; //!< unused (alignment)
|
||||
} NetGamePacketHeadT;
|
||||
|
||||
//! format of a sync packet (piggybacks onto regular packets) -- FOR INTERNAL USE ONLY
|
||||
typedef struct NetGamePacketSyncT
|
||||
{
|
||||
uint32_t repl;
|
||||
uint32_t echo;
|
||||
int16_t late;
|
||||
uint8_t psnt; //!< number of packets sent since last update
|
||||
uint8_t prcvd; //!< number of packets received since last update
|
||||
uint8_t plost; //!< number of inbound packets lost since last update
|
||||
uint8_t nsnt; //!< number of NAKs sent since last update
|
||||
uint8_t flags; //!< sync packet flags (NETGAME_SYNCFLAG_*)
|
||||
uint8_t size; //!< size of sync packet (MUST COME LAST)
|
||||
} NetGamePacketSyncT;
|
||||
|
||||
//! format of packets which are exchanged by client/server
|
||||
typedef struct NetGamePacketT
|
||||
{
|
||||
//! packet header (not sent)
|
||||
NetGamePacketHeadT head;
|
||||
|
||||
//! game packet body
|
||||
union {
|
||||
//! stream data
|
||||
struct {
|
||||
int32_t ident; //!< stream ident
|
||||
int32_t kind; //!< token
|
||||
int32_t size; //!< packet size
|
||||
uint8_t data[NETGAME_STRMPKT_DEFSIZE];//!< binary data
|
||||
} strm;
|
||||
//! raw data packet
|
||||
uint8_t data[NETGAME_DATAPKT_DEFSIZE];
|
||||
} body;
|
||||
|
||||
//! space for game packet tail
|
||||
uint8_t tail[NETGAME_DATAPKT_MAXTAIL];
|
||||
} NetGamePacketT;
|
||||
|
||||
//! format of a max-sized link packet (may be substituted for a NetGamePacketT)
|
||||
typedef struct NetGameMaxPacketT
|
||||
{
|
||||
//! packet header (not sent)
|
||||
NetGamePacketHeadT head;
|
||||
|
||||
//! game packet body
|
||||
union {
|
||||
//! stream data
|
||||
struct {
|
||||
int32_t ident; //!< stream ident
|
||||
int32_t kind; //!< token
|
||||
int32_t size; //!< packet size
|
||||
uint8_t data[NETGAME_STRMPKT_MAXSIZE];//!< binary data
|
||||
} strm;
|
||||
//! raw data packet
|
||||
uint8_t data[NETGAME_DATAPKT_MAXSIZE];
|
||||
} body;
|
||||
|
||||
//! space for game packet tail
|
||||
uint8_t tail[NETGAME_DATAPKT_MAXTAIL];
|
||||
} NetGameMaxPacketT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgamepkt_h
|
||||
|
91
src/thirdparty/dirtysdk/include/DirtySDK/game/netgameutil.h
vendored
Normal file
91
src/thirdparty/dirtysdk/include/DirtySDK/game/netgameutil.h
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File netgameutil.h
|
||||
|
||||
\Description
|
||||
Group of functions to help setup network games
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2001-2002
|
||||
|
||||
\Version 1.0 01/09/2001 (gschaefer) First Version
|
||||
\Version 1.1 11/18/2002 (jbrookes) Moved to NetGame hierarchy
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _netgameutil_h
|
||||
#define _netgameutil_h
|
||||
|
||||
/*!
|
||||
\Moduledef NetGameUtil NetGameUtil
|
||||
\Modulemember Game
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtynet.h"
|
||||
#include "DirtySDK/comm/commall.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define NETGAME_CONN_LISTEN (1) //!< listen for connect
|
||||
#define NETGAME_CONN_CONNECT (2) //!< connect to peer
|
||||
#define NETGAME_CONN_AUTO (NETGAME_CONN_LISTEN|NETGAME_CONN_CONNECT) //!< (debug only) autoconnect
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct NetGameUtilRefT NetGameUtilRefT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct the game setup module
|
||||
DIRTYCODE_API NetGameUtilRefT *NetGameUtilCreate(void);
|
||||
|
||||
// destroy the game setup module
|
||||
DIRTYCODE_API void NetGameUtilDestroy(NetGameUtilRefT *ref);
|
||||
|
||||
// reset the game setup module
|
||||
DIRTYCODE_API void NetGameUtilReset(NetGameUtilRefT *ref);
|
||||
|
||||
// set internal GameUtil parameters
|
||||
DIRTYCODE_API void NetGameUtilControl(NetGameUtilRefT *pRef, int32_t iKind, int32_t iValue);
|
||||
|
||||
// get a connection (connect/listen)
|
||||
DIRTYCODE_API int32_t NetGameUtilConnect(NetGameUtilRefT *ref, int32_t conn, const char *addr, CommAllConstructT *pConstruct);
|
||||
|
||||
// check connection status
|
||||
DIRTYCODE_API void *NetGameUtilComplete(NetGameUtilRefT *ref);
|
||||
|
||||
// return status info
|
||||
DIRTYCODE_API int32_t NetGameUtilStatus(NetGameUtilRefT *ref, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// send out an advertisement
|
||||
DIRTYCODE_API void NetGameUtilAdvert(NetGameUtilRefT *ref, const char *kind, const char *name, const char *note);
|
||||
|
||||
// cancel current advertisement
|
||||
DIRTYCODE_API void NetGameUtilWithdraw(NetGameUtilRefT *ref, const char *kind, const char *name);
|
||||
|
||||
// find ip address of a specific advertisement
|
||||
DIRTYCODE_API uint32_t NetGameUtilLocate(NetGameUtilRefT *ref, const char *kind, const char *name);
|
||||
|
||||
// return a list of all advertisements
|
||||
DIRTYCODE_API int32_t NetGameUtilQuery(NetGameUtilRefT *ref, const char *kind, char *buf, int32_t max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _netgameutil_h
|
||||
|
97
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtygif.h
vendored
Normal file
97
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtygif.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtygif.h
|
||||
|
||||
\Description
|
||||
Routines to parse and decode a GIF file.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2003-2020 Electronic Arts Inc.
|
||||
|
||||
\Version 11/13/2003 (jbrookes) First Version
|
||||
\Version 01/28/2020 (jbrookes) Added multiframe (animated) support
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtygif_h
|
||||
#define _dirtygif_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyGif DirtyGif
|
||||
\Modulemember Graph
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! structure to represent a parsed gif/gif frame
|
||||
typedef struct DirtyGifHdrT
|
||||
{
|
||||
// image info
|
||||
const uint8_t *pImageData; //!< pointer to start of gif bits
|
||||
const uint8_t *pImageEnd; //!< pointer to end of gif bits
|
||||
const uint8_t *pColorTable; //!< pointer to gif color table
|
||||
|
||||
uint32_t uNumFrames; //!< number of image frames
|
||||
|
||||
uint16_t uTop; //!< top offset of image frame
|
||||
uint16_t uLeft; //!< left offset of image frame
|
||||
uint16_t uWidth; //!< image width
|
||||
uint16_t uHeight; //!< image height
|
||||
uint16_t uNumColors; //!< number of color table entries
|
||||
uint16_t uDelay; //!< time delay after displaying current frame before moving to next in 1/100ths of a second
|
||||
|
||||
// misc info
|
||||
uint8_t bInterlaced; //!< flag indicating an interlaced image
|
||||
uint8_t bHasAlpha; //!< flag indicating transparent color present
|
||||
uint8_t uTransColor; //!< which color index is transparent
|
||||
uint8_t pad;
|
||||
} DirtyGifHdrT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// identify if image is a gif or not
|
||||
DIRTYCODE_API int32_t DirtyGifIdentify(const uint8_t *pImageData, uint32_t uImageLen);
|
||||
|
||||
// parse GIF into something we can use
|
||||
DIRTYCODE_API int32_t DirtyGifParse(DirtyGifHdrT *pGifHdr, const uint8_t *pGifData, const uint8_t *pGifEnd);
|
||||
|
||||
// parse GIF with extended info
|
||||
DIRTYCODE_API int32_t DirtyGifParseEx(DirtyGifHdrT *pGifHdr, const uint8_t *pGifData, const uint8_t *pGifEnd, DirtyGifHdrT *pFrames, uint32_t uNumFrames);
|
||||
|
||||
// decode a GIF palette to 32bit color table
|
||||
DIRTYCODE_API int32_t DirtyGifDecodePalette(DirtyGifHdrT *pGifHdr, uint8_t *pPalette, uint8_t *pPaletteEnd, uint8_t uAlpha);
|
||||
|
||||
// decode a GIF image to 8bit paletted image
|
||||
DIRTYCODE_API int32_t DirtyGifDecodeImage(DirtyGifHdrT *pGifHdr, uint8_t *pImageData, int32_t iBufWidth, int32_t iBufHeight, uint32_t bVflip);
|
||||
|
||||
// decode a GIF image to 32bit direct-color image
|
||||
DIRTYCODE_API int32_t DirtyGifDecodeImage32(DirtyGifHdrT *pGifHdr, uint8_t *pImageData, int32_t iBufWidth, int32_t iBufHeight, uint32_t bVflip);
|
||||
|
||||
// decode a GIF image to one or more 32bit direct-color images
|
||||
DIRTYCODE_API int32_t DirtyGifDecodeImage32Multi(DirtyGifHdrT *pGifHdr, DirtyGifHdrT *pFrameInfo, uint8_t *pImageData, int32_t iBufWidth, int32_t iBufHeight, int32_t iNumFrames, uint32_t bVflip);
|
||||
|
||||
// decode a specific frame of a GIF image into a single 32bit ARGB direct-color bitmap.
|
||||
DIRTYCODE_API int32_t DirtyGifDecodeImage32Frame(DirtyGifHdrT *pGifHdr, DirtyGifHdrT *pFrameInfo, uint8_t *pImageData, uint8_t *p8BitImage, int32_t iBufWidth, int32_t iBufHeight, int32_t iFrame, int32_t iNumFrames, uint32_t bVflip);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtygif_h
|
93
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtygraph.h
vendored
Normal file
93
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtygraph.h
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtygraph.h
|
||||
|
||||
\Description
|
||||
Routines for decoding an encoded graphics image.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2006-2020 Electronic Arts Inc.
|
||||
|
||||
\Version 03/09/2006 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtygraph_h
|
||||
#define _dirtygraph_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyGraph DirtyGraph
|
||||
\Modulemember Graph
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
//! supported image types
|
||||
typedef enum DirtyGraphImageTypeE
|
||||
{
|
||||
DIRTYGRAPH_IMAGETYPE_UNKNOWN = 0,
|
||||
DIRTYGRAPH_IMAGETYPE_GIF,
|
||||
DIRTYGRAPH_IMAGETYPE_JPG,
|
||||
DIRTYGRAPH_IMAGETYPE_PNG
|
||||
} DirtyGraphImageTypeE;
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! structure representing parsed image info
|
||||
typedef struct DirtyGraphInfoT
|
||||
{
|
||||
const uint8_t *pImageData; //!< pointer to start of data
|
||||
uint32_t uLength; //!< length of file
|
||||
int16_t iWidth; //!< image width
|
||||
int16_t iHeight; //!< image height
|
||||
uint16_t uNumFrames; //!< number of image frames
|
||||
uint8_t uType; //!< image type
|
||||
uint8_t _pad;
|
||||
} DirtyGraphInfoT;
|
||||
|
||||
//! opaque module state
|
||||
typedef struct DirtyGraphRefT DirtyGraphRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create module state
|
||||
DIRTYCODE_API DirtyGraphRefT *DirtyGraphCreate(void);
|
||||
|
||||
// done with module state
|
||||
DIRTYCODE_API void DirtyGraphDestroy(DirtyGraphRefT *pRef);
|
||||
|
||||
// parse the header
|
||||
DIRTYCODE_API int32_t DirtyGraphDecodeHeader(DirtyGraphRefT *pRef, DirtyGraphInfoT *pInfo, const uint8_t *pImageData, uint32_t uImageLen);
|
||||
|
||||
// get extra image info
|
||||
DIRTYCODE_API int32_t DirtyGraphGetImageInfo(DirtyGraphRefT *pRef, DirtyGraphInfoT *pInfo, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// decode an image
|
||||
DIRTYCODE_API int32_t DirtyGraphDecodeImage(DirtyGraphRefT *pRef, DirtyGraphInfoT *pInfo, uint8_t *pImageBuf, int32_t iBufWidth, int32_t iBufHeight);
|
||||
|
||||
// decode a multiframe image
|
||||
DIRTYCODE_API int32_t DirtyGraphDecodeImageMulti(DirtyGraphRefT *pRef, DirtyGraphInfoT *pInfo, uint8_t *pImageBuf, int32_t iBufWidth, int32_t iBufHeight);
|
||||
|
||||
// decode a single frame of a multiframe image
|
||||
DIRTYCODE_API int32_t DirtyGraphDecodeImageFrame(DirtyGraphRefT *pDirtyGraph, DirtyGraphInfoT *pInfo, uint8_t *pImageBuf, int32_t iBufWidth, int32_t iBufHeight, int32_t iFrame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtygraph_h
|
95
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtyjpg.h
vendored
Normal file
95
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtyjpg.h
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtyjpg.h
|
||||
|
||||
\Description
|
||||
Routines to parse and decode a JPEG image file. JFIF and EXIF file formats
|
||||
are supported.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2006 Electronic Arts Inc.
|
||||
|
||||
\Version 02/23/2006 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtyjpg_h
|
||||
#define _dirtyjpg_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyJpg DirtyJpg
|
||||
\Modulemember Graph
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define DIRTYJPG_ERR_NONE (0)
|
||||
#define DIRTYJPG_ERR_NOMAGIC (-1)
|
||||
#define DIRTYJPG_ERR_TOOSHORT (-2)
|
||||
#define DIRTYJPG_ERR_NOBUFFER (-3)
|
||||
#define DIRTYJPG_ERR_BADSTATE (-4)
|
||||
#define DIRTYJPG_ERR_BADFRAME (-5)
|
||||
#define DIRTYJPG_ERR_BADVERS (-6)
|
||||
#define DIRTYJPG_ERR_ENDOFDATA (-7)
|
||||
#define DIRTYJPG_ERR_BADDQT (-8)
|
||||
#define DIRTYJPG_ERR_BADDHT (-9)
|
||||
#define DIRTYJPG_ERR_BADSOF0 (-10)
|
||||
#define DIRTYJPG_ERR_BITDEPTH (-11) // unsupported bitdepth
|
||||
#define DIRTYJPG_ERR_DECODER (-12) // decoding error
|
||||
#define DIRTYJPG_ERR_NOSUPPORT (-13) // unsupported feature
|
||||
#define DIRTYJPG_ERR_NOFORMAT (-14) // unsupported format (not JFIF or EXIF)
|
||||
|
||||
typedef struct DirtyJpgStateT DirtyJpgStateT;
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! structure to represent a parsed gif
|
||||
typedef struct DirtyJpgHdrT
|
||||
{
|
||||
// image info
|
||||
const uint8_t *pImageData; //!< pointer to start of data
|
||||
uint32_t uLength; //!< length of file
|
||||
uint32_t uWidth; //!< image width
|
||||
uint32_t uHeight; //!< image height
|
||||
} DirtyJpgHdrT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create module state
|
||||
DIRTYCODE_API DirtyJpgStateT *DirtyJpgCreate(void);
|
||||
|
||||
// reset to default
|
||||
DIRTYCODE_API void DirtyJpgReset(DirtyJpgStateT *pState);
|
||||
|
||||
// done with module state
|
||||
DIRTYCODE_API void DirtyJpgDestroy(DirtyJpgStateT *pState);
|
||||
|
||||
// identify if image is a jpg or not
|
||||
DIRTYCODE_API int32_t DirtyJpgIdentify(DirtyJpgStateT *pState, const uint8_t *pImage, uint32_t uLength);
|
||||
|
||||
// parse the header
|
||||
DIRTYCODE_API int32_t DirtyJpgDecodeHeader(DirtyJpgStateT *pState, DirtyJpgHdrT *pJpgHdr, const uint8_t *pImage, uint32_t uLength);
|
||||
|
||||
// parse the image
|
||||
DIRTYCODE_API int32_t DirtyJpgDecodeImage(DirtyJpgStateT *pState, DirtyJpgHdrT *pJpgHdr, uint8_t *pImageData, int32_t iBufWidth, int32_t iBufHeight);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtyjpg_h
|
134
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtypng.h
vendored
Normal file
134
src/thirdparty/dirtysdk/include/DirtySDK/graph/dirtypng.h
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File dirtypng.h
|
||||
|
||||
\Description
|
||||
Routines to decode a PNG into a raw image and palette. These routines
|
||||
were written from scratch based on the published specifications. The
|
||||
functions and style were heavily based on the dirtygif.c and dirtyjpeg.c
|
||||
files coded by James Brookes.
|
||||
|
||||
Supported features
|
||||
Bit Depth of 1, 2, 4, and 8
|
||||
Colour Type 0, 2, 4, 6 (grayscale, truecolor, grayscale with alpha, truecolor with alpha)
|
||||
Noncompressed blocks, statically compressed blocks, dynamically compressed blocks
|
||||
Zlib compression levels 0, 1, 2 and 9 (none through maximum)
|
||||
Interlace method Adam7
|
||||
Filter types 0-4 (none, sub, up, average, paeth)
|
||||
|
||||
Unsupported features
|
||||
Bit Depth of 16 support
|
||||
Colour Type 3 (Indexed Color support)
|
||||
PLTE chunk support
|
||||
Ancillary chunk support
|
||||
|
||||
\Notes
|
||||
References:
|
||||
[1] http://www.w3.org/TR/PNG/
|
||||
[2] http://www.gzip.org/zlib/rfc1950.pdf
|
||||
[3] http://www.gzip.org/zlib/rfc1951.pdf
|
||||
[4] http://www.zlib.net/feldspar.html
|
||||
[5] http://www.schaik.com/pngsuite/#basic
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2007 Electronic Arts Inc.
|
||||
|
||||
\Version 02/05/2007 (christianadam) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _dirtypng_h
|
||||
#define _dirtypng_h
|
||||
|
||||
/*!
|
||||
\Moduledef DirtyPng DirtyPng
|
||||
\Modulemember Graph
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define DIRTYPNG_ERR_NONE (0)
|
||||
#define DIRTYPNG_ERR_TOOSHORT (-1)
|
||||
#define DIRTYPNG_ERR_BADCRC (-2)
|
||||
#define DIRTYPNG_ERR_BADTYPE (-3)
|
||||
#define DIRTYPNG_ERR_BADCOLOR (-4)
|
||||
#define DIRTYPNG_ERR_BADDEPTH (-5)
|
||||
#define DIRTYPNG_ERR_BADCOMPR (-6)
|
||||
#define DIRTYPNG_ERR_BADFILTR (-7)
|
||||
#define DIRTYPNG_ERR_BADINTRL (-8)
|
||||
#define DIRTYPNG_ERR_ALLOCFAIL (-9)
|
||||
#define DIRTYPNG_ERR_TYPEMISS (-10)
|
||||
#define DIRTYPNG_ERR_BADORDER (-11)
|
||||
#define DIRTYPNG_ERR_TYPEDUPL (-12)
|
||||
#define DIRTYPNG_ERR_UNKNCRIT (-13)
|
||||
#define DIRTYPNG_ERR_BADCM (-14)
|
||||
#define DIRTYPNG_ERR_BADCI (-15)
|
||||
#define DIRTYPNG_ERR_BADFLG (-16)
|
||||
#define DIRTYPNG_ERR_FDICTSET (-17)
|
||||
#define DIRTYPNG_ERR_BADBTYPE (-18)
|
||||
#define DIRTYPNG_ERR_NOBLKEND (-19)
|
||||
#define DIRTYPNG_ERR_BADBLKLEN (-20)
|
||||
#define DIRTYPNG_ERR_MAXCODES (-21)
|
||||
#define DIRTYPNG_ERR_NOCODES (-22)
|
||||
#define DIRTYPNG_ERR_BADCODE (-23)
|
||||
#define DIRTYPNG_ERR_INVFILE (-24)
|
||||
#define DIRTYPNG_ERR_UNKNOWN (-25)
|
||||
|
||||
typedef struct DirtyPngStateT DirtyPngStateT;
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! structure to represent a parsed png
|
||||
typedef struct DirtyPngHdrT
|
||||
{
|
||||
// image info
|
||||
const uint8_t *pImageData; //!< pointer to start of png bits
|
||||
const uint8_t *pImageEnd; //!< pointer to end of png bits
|
||||
uint32_t uWidth; //!< image width
|
||||
uint32_t uHeight; //!< image height
|
||||
|
||||
// misc info
|
||||
int8_t iBitDepth; //!< bit depth of the image
|
||||
int8_t iColourType; //!< colour type of the image
|
||||
int8_t iCompression; //!< compression method of the image
|
||||
int8_t iFilter; //!< filter method of the image
|
||||
int8_t iInterlace; //!< interlace method of the image
|
||||
} DirtyPngHdrT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create module state
|
||||
DIRTYCODE_API DirtyPngStateT *DirtyPngCreate(void);
|
||||
|
||||
// done with module state
|
||||
DIRTYCODE_API void DirtyPngDestroy(DirtyPngStateT *pState);
|
||||
|
||||
// identify if image is a png or not
|
||||
DIRTYCODE_API int32_t DirtyPngIdentify(const uint8_t *pImageData, uint32_t uImageLen);
|
||||
|
||||
// parse PNG into something we can use
|
||||
DIRTYCODE_API int32_t DirtyPngParse(DirtyPngStateT *pState, DirtyPngHdrT *pPngHdr, const uint8_t *pImageData, const uint8_t *pImageEnd);
|
||||
|
||||
// decode a PNG image
|
||||
DIRTYCODE_API int32_t DirtyPngDecodeImage(DirtyPngStateT *pState, DirtyPngHdrT *pPngHdr, uint8_t *pImageData, int32_t iBufWidth, int32_t iBufHeight);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _dirtypng_h
|
118
src/thirdparty/dirtysdk/include/DirtySDK/misc/privilegeapi.h
vendored
Normal file
118
src/thirdparty/dirtysdk/include/DirtySDK/misc/privilegeapi.h
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File privilegeapi.h
|
||||
|
||||
\Description
|
||||
Check first party privileges and parental controls
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013.
|
||||
|
||||
\Version 09/02/13 (mcorcoran) First Version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _privilegeapi_h
|
||||
#define _privilegeapi_h
|
||||
|
||||
/*!
|
||||
\Moduledef PrivilegeApi PrivilegeApi
|
||||
\Modulemember User
|
||||
*/
|
||||
//@{
|
||||
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct PrivilegeApiRefT PrivilegeApiRefT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
typedef enum PrivilegeApiPrivE
|
||||
{
|
||||
PRIVILEGEAPI_PRIV_INVALID = (0),
|
||||
PRIVILEGEAPI_PRIV_COMMUNICATION_VOICE_INGAME = (-1),
|
||||
PRIVILEGEAPI_PRIV_COMMUNICATION_VOICE_SKYPE = (-2),
|
||||
PRIVILEGEAPI_PRIV_VIDEO_COMMUNICATIONS = (-3),
|
||||
PRIVILEGEAPI_PRIV_COMMUNICATIONS = (-4),
|
||||
PRIVILEGEAPI_PRIV_USER_CREATED_CONTENT = (-5),
|
||||
PRIVILEGEAPI_PRIV_MULTIPLAYER_SESSIONS_REALTIME = (-6),
|
||||
PRIVILEGEAPI_PRIV_DOWNLOAD_FREE_CONTENT = (-7),
|
||||
PRIVILEGEAPI_PRIV_FITNESS_UPLOAD = (-8),
|
||||
PRIVILEGEAPI_PRIV_VIEW_FRIENDS_LIST = (-9),
|
||||
PRIVILEGEAPI_PRIV_SHARE_KINECT_CONTENT = (-10),
|
||||
PRIVILEGEAPI_PRIV_MULTIPLAYER_PARTIES = (-11),
|
||||
PRIVILEGEAPI_PRIV_CLOUD_GAMING_MANAGE_SESSION = (-12),
|
||||
PRIVILEGEAPI_PRIV_CLOUD_GAMING_JOIN_SESSION = (-13),
|
||||
PRIVILEGEAPI_PRIV_CLOUD_SAVED_GAMES = (-14),
|
||||
PRIVILEGEAPI_PRIV_PREMIUM_CONTENT = (-15),
|
||||
PRIVILEGEAPI_PRIV_INTERNET_BROWSER = (-16),
|
||||
PRIVILEGEAPI_PRIV_SUBSCRIPTION_CONTENT = (-17),
|
||||
PRIVILEGEAPI_PRIV_PREMIUM_VIDEO = (-18),
|
||||
PRIVILEGEAPI_PRIV_GAME_DVR = (-19),
|
||||
PRIVILEGEAPI_PRIV_SOCIAL_NETWORK_SHARING = (-20),
|
||||
PRIVILEGEAPI_PRIV_PURCHASE_CONTENT = (-21),
|
||||
PRIVILEGEAPI_PRIV_PROFILE_VIEWING = (-22),
|
||||
PRIVILEGEAPI_PRIV_PRESENCE = (-23),
|
||||
PRIVILEGEAPI_PRIV_CONTENT_AUTHOR = (-24),
|
||||
PRIVILEGEAPI_PRIV_UNSAFE_PROGRAMMING = (-25),
|
||||
PRIVILEGEAPI_PRIV_MULTIPLAYER_SESSIONS_ASYNC = (-26),
|
||||
PRIVILEGEAPI_PRIV_ONLINE_ACCESS = (-27),
|
||||
PRIVILEGEAPI_PRIV_EA_ACCESS = (256)
|
||||
} PrivilegeApiPrivE;
|
||||
|
||||
#define PRIVILEGEAPI_STATUS_NONE (0x0000)
|
||||
#define PRIVILEGEAPI_STATUS_IN_PROGRESS (0x0001)
|
||||
#define PRIVILEGEAPI_STATUS_GRANTED (0x0002)
|
||||
#define PRIVILEGEAPI_STATUS_GRANTED_FRIENDS_ONLY (0x0004)
|
||||
#define PRIVILEGEAPI_STATUS_RESTRICTED (0x0008)
|
||||
#define PRIVILEGEAPI_STATUS_BANNED (0x0010)
|
||||
#define PRIVILEGEAPI_STATUS_PURCHASE_REQUIRED (0x0020)
|
||||
#define PRIVILEGEAPI_STATUS_ABORTED (0x0040)
|
||||
#define PRIVILEGEAPI_STATUS_ERROR (0x0080)
|
||||
#define PRIVILEGEAPI_STATUS_ADDITIONAL_CHECKS_REQUIRED (0x0100)
|
||||
#define PRIVILEGEAPI_STATUS_UNDERAGE (0x0200)
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// creates the module
|
||||
DIRTYCODE_API PrivilegeApiRefT *PrivilegeApiCreate(void);
|
||||
|
||||
// destroys the module
|
||||
DIRTYCODE_API int32_t PrivilegeApiDestroy(PrivilegeApiRefT *pRef);
|
||||
|
||||
// checks for the existance of 1 or more privileges for a given user
|
||||
DIRTYCODE_API int32_t PrivilegeApiCheckPrivilegesAsync(PrivilegeApiRefT *pRef, int32_t iUserIndex, const PrivilegeApiPrivE *pPrivileges, int32_t iPrivilegeCount, int32_t *pHint);
|
||||
|
||||
// checks for the existance of 1 or more privileges for a given user, and show the user a system provided UI in the even tthe user does not have the requested privileges
|
||||
DIRTYCODE_API int32_t PrivilegeApiCheckPrivilegesAsyncWithUi(PrivilegeApiRefT *pRef, int32_t iUserIndex, const PrivilegeApiPrivE *pPrivileges, int32_t iPrivilegeCount, int32_t *pHint, const char *pUiMessage);
|
||||
|
||||
// checks/polls for the result of a given request id returned from the PrivilegeApiCheckPrivilegesAsync() functions
|
||||
DIRTYCODE_API int32_t PrivilegeApiCheckResult(PrivilegeApiRefT *pRef, int32_t iRequestId);
|
||||
|
||||
// frees up a request id once you are finished with it
|
||||
DIRTYCODE_API int32_t PrivilegeApiReleaseRequest(PrivilegeApiRefT *pRef, int32_t iRequestId);
|
||||
|
||||
// aborts a currently executing async request
|
||||
DIRTYCODE_API int32_t PrivilegeApiAbort(PrivilegeApiRefT *pRef, int32_t iRequestId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif
|
76
src/thirdparty/dirtysdk/include/DirtySDK/misc/qosclient.h
vendored
Normal file
76
src/thirdparty/dirtysdk/include/DirtySDK/misc/qosclient.h
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File qosclient.h
|
||||
|
||||
\Description
|
||||
Main include for the Quality of Service module.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2017 Electronic Arts Inc.
|
||||
|
||||
\Version 1.0 04/07/2017 (cvienneau) 2.0
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _qosclient_h
|
||||
#define _qosclient_h
|
||||
|
||||
/*!
|
||||
\Moduledef QosClient QosClient
|
||||
\Modulemember Misc
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/misc/qoscommon.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Forward Declarations *********************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct QosClientRefT QosClientRefT;
|
||||
|
||||
//! event callback function prototype
|
||||
typedef void (QosClientCallbackT)(QosClientRefT *pQosClient, QosCommonProcessedResultsT *pResults, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module state
|
||||
DIRTYCODE_API QosClientRefT *QosClientCreate(QosClientCallbackT *pCallback, void *pUserData, uint16_t uListenPort);
|
||||
|
||||
// let the module do processing
|
||||
DIRTYCODE_API void QosClientUpdate(QosClientRefT *pQosClient);
|
||||
|
||||
// begin QOS process managed by the QOS coordinator
|
||||
DIRTYCODE_API void QosClientStart(QosClientRefT *pQosClient, const char *pStrCoordinatorAddr, uint16_t uPort, const char * strQosProfile);
|
||||
|
||||
// change the behavior of the QOS system
|
||||
DIRTYCODE_API int32_t QosClientControl(QosClientRefT *pQosClient, int32_t iControl, int32_t iValue, void *pValue);
|
||||
|
||||
// get the status, of the QOS system
|
||||
DIRTYCODE_API int32_t QosClientStatus(QosClientRefT *pQosClient, int32_t iSelect, int32_t iData, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// destroy the module state
|
||||
DIRTYCODE_API void QosClientDestroy(QosClientRefT *pQosClient);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _filename_h
|
||||
|
297
src/thirdparty/dirtysdk/include/DirtySDK/misc/qoscommon.h
vendored
Normal file
297
src/thirdparty/dirtysdk/include/DirtySDK/misc/qoscommon.h
vendored
Normal file
@ -0,0 +1,297 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File qoscommon.h
|
||||
|
||||
\Description
|
||||
This code declares shared items between client and server of the QOS system.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2017 Electronic Arts Inc.
|
||||
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _qoscommon_h
|
||||
#define _qoscommon_h
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyaddr.h"
|
||||
#include "DirtySDK/dirtysock/dirtynet.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
#define QOS_COMMON_HMAC_TYPE (CRYPTHASH_SHA256) //!< a secure strong hashing algorithm
|
||||
#define QOS_COMMON_HMAC_SIZE (32) //!< CRYPTSHA256_HASHSIZE
|
||||
#define QOS_COMMON_SECURE_KEY_LENGTH (16) //!< length of random data as key, in generation of hmac
|
||||
#define QOS_COMMON_SIZEOF_PROBE_DATA (45) //!< total byte count of probe, excluding hmac
|
||||
#define QOS_COMMON_PROBE_PROTOCOL_ID ('qos2') //!< probe packets will all start with this to identify them as being the QOS 2 protocol
|
||||
#define QOS_COMMON_PROBE_VERSION_MAJOR (2) //!< identifies changes to QosCommonProbePacketT, 2 bytes, first byte indicates api breaking
|
||||
#define QOS_COMMON_PROBE_VERSION_MINOR (0) //!< second byte compatible bug fixes.
|
||||
#define QOS_COMMON_PROBE_VERSION ((QOS_COMMON_PROBE_VERSION_MAJOR << 8) | QOS_COMMON_PROBE_VERSION_MINOR) //!< the combined major, minor version bytes.
|
||||
#define QOS_COMMON_MIN_PACKET_SIZE (QOS_COMMON_SIZEOF_PROBE_DATA + QOS_COMMON_HMAC_SIZE) //!< size of on wire representation of the probe packet
|
||||
#define QOS_COMMON_MAX_PACKET_SIZE (SOCKET_MAXUDPRECV) //!< maximum probe/packet length
|
||||
#define QOS_COMMON_MAX_PROBE_COUNT (32) //!< maximum probes per request
|
||||
#define QOS_COMMON_MAX_SITES (32) //!< maximum sites we can test against at one time
|
||||
#define QOS_COMMON_MAX_CONTROL_CONFIGS (6) //!< maximum number of QosClientControl selectors we can include in the request
|
||||
#define QOS_COMMON_MAX_TESTS (4) //!< latency, bandwidthUP, bandwidthDown; and extra room for something we haven't considered
|
||||
#define QOS_COMMON_MAX_RESULTS (QOS_COMMON_MAX_SITES * QOS_COMMON_MAX_TESTS) //!< highest number of possible results we can generate
|
||||
#define QOS_COMMON_MAX_URL_LENGTH (256) //!< size used for URL strings
|
||||
#define QOS_COMMON_MAX_RPC_STRING (128) //!< size used for typical strings
|
||||
#define QOS_COMMON_MAX_RPC_STRING_SHORT (16) //!< size used for strings we expect to be very short
|
||||
#define QOS_COMMON_MAX_RPC_BODY_SIZE (1024 * 200) //!< rpc messages should never exceed this size, raw results are our biggest message
|
||||
#define QOS_COMMON_DEFAULT_RPC_BODY_SIZE (QOS_COMMON_MAX_RPC_BODY_SIZE / 10) //!< An amount of space that will usually be enough to receive an rpc message into
|
||||
#define QOS_COMMON_CONTENT_TYPE ("application/grpc") //!< http content type, everything is protobuff
|
||||
#define QOS_COMMON_SERVER_URL ("/eadp.qoscoordinator.QOSCoordinatorRegistration/registerServer") //!< used by server to register to the QOS server, and heartbeat to refresh its availability
|
||||
#define QOS_COMMON_CLIENT_URL ("/eadp.qoscoordinator.QOSCoordinator/ClientCall") //!< used by client to request config and push back final results
|
||||
|
||||
|
||||
// flags contained in probe packets
|
||||
#define QOS_COMMON_PACKET_FLAG_LAST_PROBE (1) //!< set if the client expects this is the last packet in this test
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! just enough space to hold a address family, port, and an v4 or v6 address. Used for storage or communicating address on the wire, never used to actually send/recv.
|
||||
typedef struct QosCommonAddrT
|
||||
{
|
||||
union
|
||||
{
|
||||
union
|
||||
{
|
||||
uint8_t aBytes[16];
|
||||
uint16_t aWords[8];
|
||||
uint32_t aDwords[4];
|
||||
}v6;
|
||||
uint32_t v4;
|
||||
}addr;
|
||||
uint16_t uFamily;
|
||||
uint16_t uPort;
|
||||
} QosCommonAddrT;
|
||||
|
||||
//! describes the configuration for a particular QOS test
|
||||
typedef struct QosCommonTestT
|
||||
{
|
||||
char strTestName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< name of the test
|
||||
char strSiteName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< alias of target QOS server
|
||||
uint16_t uProbeSizeUp; //!< minimum size of the probe, the probe will be padded with extra data to reach this size
|
||||
uint16_t uProbeSizeDown; //!< minimum size of the probe, the probe will be padded with extra data to reach this size
|
||||
uint16_t uTimeout; //!< maximum amount of time before giving up on completing the test
|
||||
uint16_t uMinTimeBetwenProbes; //!< minimum amount of time between each probe sent from the client
|
||||
uint16_t uTimeTillResend; //!< if we haven't got the expected number of responses back in this much time, we will send more probes
|
||||
uint16_t uInitSyncTimeout; //!< the amount of time we might wait to synchronize all requests together
|
||||
uint8_t uProbeCountUp; //!< number of probes to send to the server
|
||||
uint8_t uProbeCountDown; //!< number of probes there server should respond with for each probe received
|
||||
uint8_t uResendExtraProbeCount; //!< in the case of finding packet loss, we request the lost packets again with a few extras, to reduce the chance that those are lost too
|
||||
uint8_t uAcceptableLostProbeCount; //!< typically we would receive (uProbeCountUp * uProbeCountDown) probes, this indicates how many less probes we can receive without triggering a re-send
|
||||
} QosCommonTestT;
|
||||
|
||||
//! describes QosClientControl overrides that should be executed before doing any QosTests
|
||||
typedef struct QosCommonControlConfigT
|
||||
{
|
||||
char strValue[QOS_COMMON_MAX_RPC_STRING]; //!< string value, such as QosClientControl(mQosClient, 'sprt', 0, strValue);
|
||||
char strControl[5]; //!< dirty sdks four character code identifier, usually in the form of 'wxzy'
|
||||
int32_t iValue; //!< integer value, such as QosClientControl(mQosClient, 'lprt', iValue, NULL);
|
||||
} QosCommonControlConfigT;
|
||||
|
||||
//! describes a site, QOS Tests are performed against a QOS/ping Site
|
||||
typedef struct QosCommonSiteT
|
||||
{
|
||||
char strSiteName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< identifies where a site is, such as bio-sjc
|
||||
char strProbeAddr[QOS_COMMON_MAX_RPC_STRING]; //!< url to communicate with the server
|
||||
uint8_t aSecureKey[QOS_COMMON_SECURE_KEY_LENGTH]; //!< key used in generating hmac
|
||||
uint16_t uProbePort; //!< port to use when communicating
|
||||
uint16_t uProbeVersion; //!< the version the site is operating with
|
||||
} QosCommonSiteT;
|
||||
|
||||
//! a collection of sites, control configs and tests to describe what actions the client should be taking
|
||||
typedef struct QosCommonClientConfigT
|
||||
{
|
||||
QosCommonSiteT aSites[QOS_COMMON_MAX_SITES]; //!< list of sites that are potential targets
|
||||
QosCommonControlConfigT aControlConfigs[QOS_COMMON_MAX_CONTROL_CONFIGS]; //!< list of control settings to be run before doing tests
|
||||
QosCommonTestT aQosTests[QOS_COMMON_MAX_TESTS]; //!< list tests to be done
|
||||
QosCommonAddrT clientAddressFromCoordinator; //!< the client must report its external address to the QOS server, the coordinator will initialize this to what it sees the clients address as
|
||||
uint8_t uNumSites; //!< number of QosCommonSiteT contained in aSites
|
||||
uint8_t uNumControlConfigs; //!< number of QosCommonControlConfigT contained in aControlConfigs
|
||||
uint8_t uNumQosTests; //!< number of QosCommonTestT contained aQosTests
|
||||
} QosCommonClientConfigT;
|
||||
|
||||
//!< a firewall or NAT (network address translation) indicates how difficult it is to make a connection with this location
|
||||
typedef enum QosCommonFirewallTypeE
|
||||
{
|
||||
QOS_COMMON_FIREWALL_UNKNOWN,
|
||||
QOS_COMMON_FIREWALL_OPEN,
|
||||
QOS_COMMON_FIREWALL_MODERATE,
|
||||
QOS_COMMON_FIREWALL_STRICT,
|
||||
QOS_COMMON_FIREWALL_NUMNATTYPES //!< max number of NAT types, must be at the end
|
||||
} QosCommonFirewallTypeE;
|
||||
|
||||
//! contains latency and bandwidth results for a given site
|
||||
typedef struct QosCommonTestResultT
|
||||
{
|
||||
char strSiteName[QOS_COMMON_MAX_RPC_STRING_SHORT];
|
||||
uint32_t uMinRTT;
|
||||
uint32_t uUpbps;
|
||||
uint32_t uDownbps;
|
||||
uint32_t hResult;
|
||||
} QosCommonTestResultT;
|
||||
|
||||
//! the coordinator will examine a QosCommonRawResultsT and produce usable QosCommonProcessedResultsT
|
||||
typedef struct QosCommonProcessedResultsT
|
||||
{
|
||||
QosCommonTestResultT aTestResults[QOS_COMMON_MAX_SITES]; //!< an ordered list (by "best" site, coordinator's decision) of all test results
|
||||
QosCommonAddrT clientExternalAddress; //!< this is the address the coordinator recommends using for communication to this client
|
||||
QosCommonFirewallTypeE eFirewallType; //!< this is what the coordinator classifies the firewall type to be
|
||||
uint32_t uNumResults; //!< number of results found in aTestResults
|
||||
uint32_t uTimeTillRetry; //!< if this is != 0, the QOS server wants us to check back in this many ms for a new test
|
||||
uint32_t hResult; //!< holds the error/status code of the request
|
||||
} QosCommonProcessedResultsT;
|
||||
|
||||
//! the coordinator responds with configuration or results
|
||||
typedef struct QosCommonCoordinatorToClientResponseT
|
||||
{
|
||||
QosCommonClientConfigT configuration; //!< what does the coordinator want the client to do
|
||||
QosCommonProcessedResultsT results; //!< contains the processed data from the coordinator, this will be provided if there coordinator doesn't have more tests for the client to do
|
||||
uint32_t uServiceRequestID; //!< number uniquely identifies this transaction taking place between client and coordinator
|
||||
} QosCommonCoordinatorToClientResponseT;
|
||||
|
||||
//! sent to and from the QOS server as a udp probe, note QosCommonSerializeProbePacket and QosCommonDeserializeProbePacket determines on wire packing and order
|
||||
typedef struct QosCommonProbePacketT
|
||||
{
|
||||
QosCommonAddrT clientAddressFromService; //!< initially the client address from coordinator, however address from server prospective takes precedence, used to authenticate the packet is coming from the address that generated it
|
||||
uint32_t uProtocol; //!< QOS 2.0 packets will always contain 'qos2' for easy identification.
|
||||
uint32_t uServiceRequestId; //!< provided by the QosCoordinator, unique to the client doing multiple QOS actions, used to identify which server resources this client is using
|
||||
uint32_t uServerReceiveTime; //!< time the server received this probe from the client
|
||||
uint16_t uServerSendDelta; //!< duration the server held onto the packet before sending the response probe, this is latency added by the server process
|
||||
uint16_t uVersion; //!< uniquely identifies protocol
|
||||
uint16_t uProbeSizeUp; //!< indicates how big this probe is, including any padding for bandwidth
|
||||
uint16_t uProbeSizeDown; //!< indicates how big this probe is, including any padding for bandwidth
|
||||
uint16_t uClientRequestId; //!< provided by the client, unique to a particular QOS action, used to pair request and responses together
|
||||
uint8_t uProbeCountUp; //!< count index of this probe
|
||||
uint8_t uProbeCountDown; //!< from client (number of probes there server should respond with for each probe received) from server (count index of this probe)
|
||||
uint8_t uExpectedProbeCountUp; //!< number of probes the client expects to send to the sever in this test (assuming no packet loss)
|
||||
} QosCommonProbePacketT;
|
||||
|
||||
//! a single QOS probe result information
|
||||
typedef struct QosCommonProbeResultT
|
||||
{
|
||||
uint32_t uClientSendTime; //!< time the client initially sent this QOS probe
|
||||
uint32_t uServerReceiveTime; //!< time the server received this probe from the client (note that server and client time are not in sync)
|
||||
uint16_t uServerSendDelta; //!< duration the server held onto the packet before sending the response probe, this is latency added by the server process
|
||||
uint16_t uClientReceiveDelta; //!< duration since sending before the client received response from the QOS server for this probe
|
||||
} QosCommonProbeResultT;
|
||||
|
||||
//!< after the client performs the tests, raw results are provided to the coordinator for analysis
|
||||
//! Its expected each QosCommonRawResultsT can be used to generate latency values, bandwidth values, with two QosCommonRawResultsT firewall values can be calculated
|
||||
typedef struct QosCommonRawResultsT
|
||||
{
|
||||
QosCommonProbeResultT aProbeResult[QOS_COMMON_MAX_PROBE_COUNT]; //!< a list of individual probe timings
|
||||
QosCommonAddrT clientAddressFromServer; //!< clients address from prospective of the QOS server
|
||||
char strSiteName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< identifies where a site is, such as bio-sjc
|
||||
char strTestName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< identifies which test, such as latency, bandwidthUp, bandwidthDown
|
||||
uint32_t hResult; //!< holds the error/status code of the request
|
||||
uint8_t uProbeCountUp; //!< number of probes the request sent when all retrying and everything is done (usually same as uProbeCountRequestedUp if no probes were lost, otherwise we send more)
|
||||
uint8_t uProbeCountDown; //!< number of valid probes from this request that came back from the server (usually same as uProbeCountRequestedDown at the end unless an error or probes lost)
|
||||
uint8_t uProbeCountHighWater; //!< the highest count of probe we receive back
|
||||
//note, uProbeCountHighWater, uProbeCountDown, and uProbeCountUp aren't shared with the coordinator
|
||||
} QosCommonRawResultsT ;
|
||||
|
||||
//! data the client will tell the coordinator about itself (aside from test results) to help it make its decisions
|
||||
typedef struct QosCommonClientModifiersT
|
||||
{
|
||||
QosCommonAddrT clientAddressInternal; //!< address the client believes it is using
|
||||
char strPlatform[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< a string describing which platform the client is
|
||||
QosCommonFirewallTypeE eOSFirewallType; //!< the firewall type that the client OS suggests it might be
|
||||
uint32_t uPacketQueueRemaining; //!< number of spots left in the packet queue after the client has done its tests, a 0 value indicates a problem
|
||||
uint32_t uStallCountCoordinator; //!< number of stall events encountered when attempting to communicate with the coordinator
|
||||
uint32_t uStallDurationCoordinator; //!< total duration of time spent stalled while communicating with the coordinator
|
||||
uint32_t uStallCountProbe; //!< number of stall events encountered when attempting to send probes to the qos server
|
||||
uint32_t uStallDurationProbe; //!< total duration of time spent stalled while communicating with the qos server
|
||||
uint32_t hResult; //!< current error status of the QosClient module, can be used to report errors to the coordinator
|
||||
} QosCommonClientModifiersT;
|
||||
|
||||
//! the client informs the coordinator of who it is and any results it has gathered in order to get configuration or processed "final" results
|
||||
typedef struct QosCommonClientToCoordinatorRequestT
|
||||
{
|
||||
QosCommonRawResultsT aResults[QOS_COMMON_MAX_RESULTS]; //!< a set of raw results for each site, for each test performed
|
||||
char strQosProfile[QOS_COMMON_MAX_RPC_STRING]; //!< a string describing which setting the coordinator should use for this title. (likely service name, like fifa-pc-2017)
|
||||
uint32_t uServiceRequestID; //!< number uniquely identifies this transaction taking place between client and coordinator
|
||||
uint32_t uNumResults; //!< number results in aResults, if the client has results to report
|
||||
uint16_t uProbeVersion; //!< uniquely identifies protocol
|
||||
QosCommonClientModifiersT clientModifiers; //!< a set of fields the client wants to share with the coordinator such as health information to use in decision process
|
||||
} QosCommonClientToCoordinatorRequestT;
|
||||
|
||||
//! the QOS server will request to be registered with the coordinator
|
||||
typedef struct QosCommonServerToCoordinatorRequestT
|
||||
{
|
||||
char strAddr[QOS_COMMON_MAX_RPC_STRING]; //!< url to communicate with the server
|
||||
char strSiteName[QOS_COMMON_MAX_RPC_STRING_SHORT]; //!< location where this server resides ie bio-sjc
|
||||
char strPool[QOS_COMMON_MAX_RPC_STRING]; //!< segregate servers at a given location, such as only fifa is using this server or only for special qa tests
|
||||
uint8_t aSecureKey[QOS_COMMON_SECURE_KEY_LENGTH]; //!< key used to generate hmac
|
||||
uint16_t uPort; //!< port to use when communicating
|
||||
uint16_t uCapacityPerSec; //!< maximum number of clients the coordinator should send to the server per second
|
||||
uint16_t uLastLoadPerSec; //!< number of qos tests started last second
|
||||
uint16_t uProbeVersion; //!< the probe packet version this server will operate with
|
||||
uint16_t uUpdateInterval; //!< amount of time in ms that the coordinator should wait before expecting the next heartbeat
|
||||
uint8_t bShuttingDown; //!< indicates if this server has begun to shutdown, if so no more clients should be sent to this server
|
||||
} QosCommonServerToCoordinatorRequestT;
|
||||
|
||||
//! registration message is for debug purpose only
|
||||
typedef struct QosCommonCoordinatorToServerResponseT
|
||||
{
|
||||
char strRegistrationMessage[QOS_COMMON_MAX_RPC_STRING]; //!< message provided by the coordinator for this server, likely explaining any error status
|
||||
uint32_t uMinServiceRequestID; //!< don't accept service request id's older than this
|
||||
} QosCommonCoordinatorToServerResponseT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// QosCommonClientToCoordinatorRequestT helpers
|
||||
DIRTYCODE_API uint8_t* QosCommonClientToCoordinatorRequestEncode(const QosCommonClientToCoordinatorRequestT *pClientToCoordinatorRequest, uint8_t *pBuffer, uint32_t uBuffSize, uint32_t *pOutSize);
|
||||
DIRTYCODE_API int32_t QosCommonClientToCoordinatorEstimateEncodedSize(const QosCommonClientToCoordinatorRequestT *pClientToCoordinatorRequest);
|
||||
DIRTYCODE_API void QosCommonClientToCoordinatorPrint(const QosCommonClientToCoordinatorRequestT *pClientToCoordinatorRequest, uint32_t uLogLevel);
|
||||
|
||||
// QosCommonCoordinatorToClientResponseT helpers
|
||||
DIRTYCODE_API int32_t QosCommonCoordinatorToClientResponseDecode(QosCommonCoordinatorToClientResponseT *pResponse, const uint8_t *pBuffer, uint32_t uBuffSize);
|
||||
DIRTYCODE_API void QosCommonCoordinatorToClientPrint(const QosCommonCoordinatorToClientResponseT *pResponse, uint32_t uLogLevel);
|
||||
|
||||
// QosCommonServerToCoordinatorRequestT helpers
|
||||
DIRTYCODE_API uint8_t* QosCommonServerToCoordinatorRequestEncode(const QosCommonServerToCoordinatorRequestT *pServerRegistrationRequest, uint8_t *pBuffer, uint32_t uBuffSize, uint32_t *pOutSize);
|
||||
|
||||
// QosCommonCoordinatorToServerResponseT helpers
|
||||
DIRTYCODE_API int32_t QosCommonCoordinatorToServerResponseDecode(QosCommonCoordinatorToServerResponseT *pServerRegistrationResponse, const uint8_t *pBuffer, uint32_t uBuffSize);
|
||||
|
||||
// helpers for address
|
||||
DIRTYCODE_API char* QosCommonAddrToString(const QosCommonAddrT *pAddr, char *pBuffer, int32_t iBufSize);
|
||||
DIRTYCODE_API int32_t QosCommonStringToAddr(char *pStrIn, QosCommonAddrT *pOutAddr);
|
||||
DIRTYCODE_API uint8_t QosCommonIsAddrEqual(QosCommonAddrT *pAddr1, QosCommonAddrT *pAddr2);
|
||||
DIRTYCODE_API uint8_t QosCommonIsRemappedAddrEqual(QosCommonAddrT *pAddr1, struct sockaddr *pAddr2);
|
||||
DIRTYCODE_API void QosCommonConvertAddr(QosCommonAddrT *pTargetAddr, struct sockaddr *pSourceAddr);
|
||||
|
||||
// helpers for serializing and deserializing packets
|
||||
DIRTYCODE_API uint8_t QosCommonSerializeProbePacket(uint8_t *pOutBuff, uint32_t uBuffSize, const QosCommonProbePacketT *pInPacket, uint8_t *pSecureKey);
|
||||
DIRTYCODE_API uint8_t QosCommonDeserializeProbePacket(QosCommonProbePacketT *pOutPacket, uint8_t *pInBuff, uint8_t *pSecureKey1, uint8_t *pSecureKey2);
|
||||
DIRTYCODE_API void QosCommonDeserializeProbePacketInsecure(QosCommonProbePacketT *pOutPacket, uint8_t *pInBuff);
|
||||
DIRTYCODE_API uint16_t QosCommonDeserializeClientRequestId(uint8_t *pInBuff);
|
||||
DIRTYCODE_API uint32_t QosCommonDeserializeServiceRequestId(uint8_t *pInBuff);
|
||||
|
||||
// helpers for version numbering
|
||||
DIRTYCODE_API uint16_t QosCommonMakeVersion(uint8_t uMajor, uint8_t uMinor);
|
||||
DIRTYCODE_API void QosCommonGetVersion(uint16_t uVersion, uint8_t *uMajor, uint8_t *uMinor);
|
||||
DIRTYCODE_API uint8_t QosCommonIsCompatibleVersion(uint16_t uVersion1, uint16_t uVersion2);
|
||||
DIRTYCODE_API uint8_t QosCommonIsCompatibleProbeVersion(uint16_t uVersion);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _qoscommon_h
|
||||
|
280
src/thirdparty/dirtysdk/include/DirtySDK/misc/userapi.h
vendored
Normal file
280
src/thirdparty/dirtysdk/include/DirtySDK/misc/userapi.h
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
\File userapi.h
|
||||
|
||||
\Description
|
||||
Expose first party player information
|
||||
|
||||
\Notes
|
||||
This API currently only supports Gen 4 platforms (XBox One and PS4).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2001-2013. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 05/12/13 (mcorcoran) First Version
|
||||
\Version 12/02/14 (amakoukji) API revamped
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _userapi_h
|
||||
#define _userapi_h
|
||||
|
||||
/*!
|
||||
\Moduledef UserApi UserApi
|
||||
\Modulemember User
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ********************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyuser.h"
|
||||
|
||||
#if defined(DIRTYCODE_XBOXONE) || defined(DIRTYCODE_GDK)
|
||||
#include "DirtySDK/misc/xboxone/userapixboxone.h"
|
||||
#endif
|
||||
|
||||
/*** Defines **************************************************************************************/
|
||||
|
||||
//!< Maximum sizes of various strings
|
||||
#define USERAPI_NOTIFY_LIST_MAX_SIZE (50)
|
||||
#define USERAPI_GAMERTAG_MAXLEN (128)
|
||||
#define USERAPI_AVATAR_URL_MAXLEN (256)
|
||||
#define USERAPI_DISPLAYNAME_MAXLEN (256)
|
||||
#define USERAPI_PLATFORM_NAME_MAXLEN (64)
|
||||
#define USERAPI_TITLE_NAME_MAXLEN (128)
|
||||
#define USERAPI_TITLE_ID_MAXLEN (64)
|
||||
#define USERAPI_RICH_PRES_MAXLEN (512)
|
||||
#define USERAPI_GAME_DATA_MAXLEN (172)
|
||||
|
||||
#define USERAPI_MASK_PROFILE (0x01)
|
||||
#define USERAPI_MASK_PRESENCE (0x02)
|
||||
#define USERAPI_MASK_RICH_PRESENCE (0x04)
|
||||
#define USERAPI_MASK_PROFILES (0x08)
|
||||
|
||||
/*** Macros ***************************************************************************************/
|
||||
|
||||
/*** Definitions *****************************************************************************/
|
||||
|
||||
//!< UserApi Error types
|
||||
typedef enum UserApiEventErrorE
|
||||
{
|
||||
USERAPI_ERROR_OK = 0, // Success code
|
||||
|
||||
USERAPI_ERROR_REQUEST_FAILED = -100, // Failed to retrieve id
|
||||
USERAPI_ERROR_REQUEST_NOT_FOUND, // User wasn't found
|
||||
USERAPI_ERROR_REQUEST_FORBIDDEN, // local user does not have access to requested user information
|
||||
USERAPI_ERROR_REQUEST_SERVER_ERROR, // Internal server error
|
||||
USERAPI_ERROR_REQUEST_UNAVAILABLE, // Service unavailable
|
||||
USERAPI_ERROR_REQUEST_TIMEOUT, // Profile response was not received on time
|
||||
USERAPI_ERROR_UNSUPPORTED,
|
||||
USERAPI_ERROR_INPROGRESS,
|
||||
USERAPI_ERROR_REQUEST_PARSE_FAILED,
|
||||
USERAPI_ERROR_NO_USER,
|
||||
USERAPI_ERROR_FULL
|
||||
} UserApiEventErrorE;
|
||||
|
||||
//!< Type of first party notifications
|
||||
// Note that minimal information is returned by the notifications themselves and a follow up query to the first party will often be necessary to update the internal state
|
||||
typedef enum UserApiNotifyTypeE
|
||||
{
|
||||
USERAPI_NOTIFY_PRESENCE_UPDATE = 0,
|
||||
USERAPI_NOTIFY_TITLE_UPDATE,
|
||||
USERAPI_NOTIFY_RICH_PRESENCE_UPDATE,
|
||||
USERAPI_NOTIFY_PROFILE_UPDATE
|
||||
} UserApiNotifyTypeE;
|
||||
|
||||
//!< Categories of data for UserApi callbacks
|
||||
typedef enum UserApiEventTypeE
|
||||
{
|
||||
USERAPI_EVENT_DATA = 0, // The current event has user data available
|
||||
USERAPI_EVENT_END_OF_LIST // The current event has completion data available through EventDetails.EndOfList
|
||||
} UserApiEventTypeE;
|
||||
|
||||
//!< List of possible online statuses
|
||||
typedef enum UserApiOnlineStatusE
|
||||
{
|
||||
USERAPI_PRESENCE_UNKNOWN = 0,
|
||||
USERAPI_PRESENCE_OFFLINE,
|
||||
USERAPI_PRESENCE_ONLINE,
|
||||
USERAPI_PRESENCE_AWAY
|
||||
} UserApiOnlineStatusE;
|
||||
|
||||
//!< Rich presence response data structure
|
||||
typedef struct UserApiRichPresenceT
|
||||
{
|
||||
char strData[USERAPI_RICH_PRES_MAXLEN + 1]; // Rich presence string
|
||||
char strGameData[USERAPI_GAME_DATA_MAXLEN + 1]; // GameData Base64 string
|
||||
void *pRawData;
|
||||
} UserApiRichPresenceT;
|
||||
|
||||
//!< Presence data response structure
|
||||
typedef struct UserApiPresenceT
|
||||
{
|
||||
UserApiOnlineStatusE ePresenceStatus; // online, offline, away or unknown
|
||||
char strPlatform[USERAPI_PLATFORM_NAME_MAXLEN+1]; // name of the console the user is on
|
||||
char strTitleName[USERAPI_TITLE_NAME_MAXLEN+1]; // title name
|
||||
char strTitleId[USERAPI_TITLE_ID_MAXLEN+1]; // title identifier
|
||||
uint8_t bIsPlayingSameTitle;
|
||||
void *pRawData;
|
||||
} UserApiPresenceT;
|
||||
|
||||
//!< Profile data response structure
|
||||
typedef struct UserApiProfileT
|
||||
{
|
||||
char strDisplayName[USERAPI_DISPLAYNAME_MAXLEN + 1]; // The users real name. This string will contain strGamerTag if the real name is not available
|
||||
char strGamertag [USERAPI_GAMERTAG_MAXLEN + 1]; // The users gamertag for XBox One or onlineId for PS4
|
||||
char strAvatarUrl [USERAPI_AVATAR_URL_MAXLEN + 1]; // URI pointing to the avatar image for XBox One and PS4
|
||||
uint32_t uLocale; // The users location and language encoded using the LOBBYAPI macros in dirtylang.h
|
||||
#if defined(DIRTYCODE_XBOXONE) && !defined(DIRTYCODE_GDK)
|
||||
UserApiAccessibilityT Accessibility; // Contains the accessibility settings
|
||||
#endif
|
||||
void *pRawData; // pointer to object that contain all first part data received
|
||||
} UserApiProfileT;
|
||||
|
||||
//!< General response structure
|
||||
typedef struct UserApiUserDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // A DirtySDK representation or the native user on the current platform
|
||||
uint32_t uUserDataMask; // A mask value to determine which values below are valid
|
||||
UserApiProfileT Profile; // Valid when uUserDataMask & USERAPI_MASK_PROFILE > 0
|
||||
UserApiPresenceT Presence; // Valid when uUserDataMask & USERAPI_MASK_PRESENCE > 0
|
||||
UserApiRichPresenceT RichPresence; // Valid when uUserDataMask & USERAPI_MASK_RICH_PRESENCE > 0
|
||||
} UserApiUserDataT;
|
||||
|
||||
//!< Request metadata response structure
|
||||
typedef struct UserApiEndOfListT
|
||||
{
|
||||
int32_t iTotalRequested;
|
||||
int32_t iTotalReceived;
|
||||
int32_t iTotalErrors;
|
||||
} UserApiEndOfListT;
|
||||
|
||||
//!< Container union for responses
|
||||
typedef union UserApiEventDetailsT
|
||||
{
|
||||
UserApiUserDataT UserData; // Valid when eEventType == USERAPI_EVENT_DATA
|
||||
UserApiEndOfListT EndOfList; // Valid when eEventType == USERAPI_EVENT_END_OF_LIST
|
||||
} UserApiEventDetailsT;
|
||||
|
||||
//!< User metadata fpr USERAPI_EVENT_DATA
|
||||
typedef struct UserApiEventDataT
|
||||
{
|
||||
UserApiEventErrorE eError; // Error code associated with this event
|
||||
UserApiEventTypeE eEventType; // Event type used to specify the type of data in EventDetails
|
||||
uint32_t uUserIndex; // Index of the user that made the request
|
||||
UserApiEventDetailsT EventDetails; // Contains event details specific for the eEventType event type
|
||||
} UserApiEventDataT;
|
||||
|
||||
//!< Response from data post style request
|
||||
typedef struct UserApiPostResponseT
|
||||
{
|
||||
uint32_t uUserIndex; // Index of the user that made the request
|
||||
UserApiEventErrorE eError; // HTTP Error code associated with this event
|
||||
const char *pMessage; // Message if applicable
|
||||
} UserApiPostResponseT;
|
||||
|
||||
//!< opaque module ref
|
||||
typedef struct UserApiRefT UserApiRefT;
|
||||
|
||||
//!< Title change notification data
|
||||
typedef struct UserApiNotifyTitleDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user who's presence was updated
|
||||
uint32_t uTitleId; // title that was updated
|
||||
uint32_t uUserIndex; // user the notification is for
|
||||
} UserApiNotifyTitleDataT;
|
||||
|
||||
//!< Presence change notification data, note that this remains incomplete since minimal data is provided by first parties
|
||||
typedef struct UserApiNotifyPresenceDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user who's presence was updated
|
||||
uint32_t uUserIndex; // user the notification is for
|
||||
} UserApiNotifyPresenceDataT;
|
||||
|
||||
//!< Rich presence change notification data, note that this remains incomplete since minimal data is provided by first parties
|
||||
typedef struct UserApiNotifyRichPresenceDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user who's presence was updated
|
||||
uint32_t uUserIndex; // user the notification is for
|
||||
} UserApiNotifyRichPresenceDataT;
|
||||
|
||||
//!< Rich presence change notification data, note that this remains incomplete since minimal data is provided by first parties
|
||||
typedef struct UserApiNotifyProfileUpdateDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user who's presence was updated
|
||||
uint32_t uUserIndex; // user the notification is for
|
||||
} UserApiNotifyProfileUpdateDataT;
|
||||
|
||||
//!< container union for notification data
|
||||
typedef union UserApiNotifyDataT
|
||||
{
|
||||
UserApiNotifyTitleDataT TitleData; // Valid when eNotifyType == USERAPI_NOTIFY_TITLE_UPDATE
|
||||
UserApiNotifyPresenceDataT PresenceData; // Valid when eNotifyType == USERAPI_NOTIFY_PRESENCE
|
||||
UserApiNotifyRichPresenceDataT RichPresenceData; // Valid when eNotifyType == USERAPI_NOTIFY_RICH_PRESENCE
|
||||
UserApiNotifyProfileUpdateDataT ProfileUpdateData; // Valid When eNotifyType == USERAPI_NOTIFY_PROFILE_UPDATE
|
||||
} UserApiNotifyDataT;
|
||||
|
||||
//!< callback types
|
||||
typedef void (UserApiCallbackT) (UserApiRefT *pRef, UserApiEventDataT *pUserApiEventData, void *pUserData);
|
||||
typedef void (UserApiPostCallbackT) (UserApiRefT *pRef, UserApiPostResponseT *pResponse, void *pUserData);
|
||||
typedef void (UserApiUpdateCallbackT)(UserApiRefT *pRef, UserApiNotifyTypeE eNotifyType, UserApiNotifyDataT *pData, void *pUserData);
|
||||
|
||||
/*** Function Prototypes **************************************************************************/
|
||||
|
||||
/*** Variables ************************************************************************************/
|
||||
|
||||
/*** Private Functions ****************************************************************************/
|
||||
|
||||
/*** Public Functions *****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Starts UserApi.
|
||||
DIRTYCODE_API UserApiRefT *UserApiCreate(void);
|
||||
|
||||
// Starts shutting down module. Module will not accept new requests, and will abort ongoing ones. Also, registered UserApiCallbackT callback will not be called even if there is data available for processing
|
||||
DIRTYCODE_API int32_t UserApiDestroy(UserApiRefT *pRef);
|
||||
|
||||
// Get status information.
|
||||
DIRTYCODE_API int32_t UserApiStatus(UserApiRefT *pRef, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// Control behavior of module
|
||||
DIRTYCODE_API int32_t UserApiControl(UserApiRefT *pRef, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// Starts the process to retrieve a batch of user information for players. pLookupUsers is a pointer to the first DirtyUserT, and iLookupUsersLength is the number of DirtyUserTs.
|
||||
DIRTYCODE_API int32_t UserApiRequestProfilesAsync(UserApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pLookupUsers, int32_t iLookupUsersLength, UserApiCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// Starts the process to retrieve user information of a single user. pLookupUsers is a pointer to the DirtyUserT
|
||||
DIRTYCODE_API int32_t UserApiRequestProfileAsync(UserApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pLookupUser, UserApiCallbackT *pCallback, uint32_t uUserDataMask, void *pUserData);
|
||||
|
||||
// Starts the process to retrieve Presence information of a single user. pLookupUsers is a pointer to the DirtyUserT
|
||||
DIRTYCODE_API int32_t UserApiRequestPresenceAsync(UserApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pLookupUser, UserApiCallbackT *pCallback, uint32_t uUserDataMask, void *pUserData);
|
||||
|
||||
// Starts the process to retrieve Rich Presence information of a single user. pLookupUsers is a pointer to the DirtyUserT
|
||||
DIRTYCODE_API int32_t UserApiRequestRichPresenceAsync(UserApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pLookupUser, UserApiCallbackT *pCallback, uint32_t uUserDataMask, void *pUserData);
|
||||
|
||||
// Log that a local user recently interacted with another
|
||||
DIRTYCODE_API int32_t UserApiPostRecentlyMetAsync(UserApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pPlayerMet, void *pAdditionalInfo, UserApiPostCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// Log new rich presence info; usage of this is very dependant on the first party's method of rich presence
|
||||
DIRTYCODE_API int32_t UserApiPostRichPresenceAsync(UserApiRefT *pRef, uint32_t uUserIndex, UserApiRichPresenceT *pData, UserApiPostCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// Register for callbacks
|
||||
DIRTYCODE_API int32_t UserApiRegisterUpdateEvent(UserApiRefT *pRef, uint32_t uUserIndex, UserApiNotifyTypeE eType, UserApiUpdateCallbackT *pNotifyCb, void *pUserData);
|
||||
|
||||
// Update the internal state of the module, and call registered UserApiCallbackT callback if there are GamerCard/Profile responses available. This function should be called periodically.
|
||||
DIRTYCODE_API void UserApiUpdate(UserApiRefT *pRef);
|
||||
|
||||
// cancels all pending transactions
|
||||
DIRTYCODE_API int32_t UserApiCancel(UserApiRefT *pRef, uint32_t uUserIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _userapi_h
|
251
src/thirdparty/dirtysdk/include/DirtySDK/misc/userlistapi.h
vendored
Normal file
251
src/thirdparty/dirtysdk/include/DirtySDK/misc/userlistapi.h
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
\File userlistapi.h
|
||||
|
||||
\Description
|
||||
The UserListApi module allow the user to fetche friends, blocked users and
|
||||
muted users from first parties.
|
||||
|
||||
\Notes
|
||||
This API currently only supports Gen 4 platforms (XBox One and PS4).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013.
|
||||
|
||||
\Version 04/17/13 (amakoukji)
|
||||
\Version 12/02/14 (amakoukji) API revamped
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _userlistapi_h
|
||||
#define _userlistapi_h
|
||||
|
||||
/*!
|
||||
\Moduledef UserList UserList
|
||||
\Modulemember User
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ********************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtyuser.h"
|
||||
#include "DirtySDK/misc/userapi.h"
|
||||
|
||||
#if defined (DIRTYCODE_XBOXONE) || defined (DIRTYCODE_GDK)
|
||||
#include "DirtySDK/misc/xboxone/userlistapixboxone.h"
|
||||
#elif defined (DIRTYCODE_PS5)
|
||||
#include "DirtySDK/misc/ps5/userlistapips5.h"
|
||||
#elif defined (DIRTYCODE_PS4)
|
||||
#include "DirtySDK/misc/ps4/userlistapips4.h"
|
||||
#endif
|
||||
|
||||
/*** Defines **************************************************************************************/
|
||||
|
||||
#define USERLISTAPI_ERROR_UNSUPPORTED (-1)
|
||||
#define USERLISTAPI_ERROR_INPROGRESS (-2)
|
||||
#define USERLISTAPI_ERROR_BAD_PARAM (-3)
|
||||
#define USERLISTAPI_ERROR_NO_USER (-4)
|
||||
#define USERLISTAPI_ERROR_TIMEOUT (-5)
|
||||
#define USERLISTAPI_ERROR_GUEST (-6)
|
||||
#define USERLISTAPI_ERROR_INVALID_USER (-7)
|
||||
#define USERLISTAPI_ERROR_USER_INDEX_RANGE (-8)
|
||||
#define USERLISTAPI_ERROR_RATE_LIMITED (-9)
|
||||
#define USERLISTAPI_ERROR_UNKNOWN (-99)
|
||||
|
||||
#define USERLISTAPI_MASK_PROFILE (0x01)
|
||||
#define USERLISTAPI_MASK_PRESENCE (0x02)
|
||||
#define USERLISTAPI_MASK_RICH_PRESENCE (0x04)
|
||||
|
||||
#define USERLISTAPI_NOTIFY_LIST_MAX_SIZE (50)
|
||||
|
||||
typedef enum UserListApiTypeE
|
||||
{
|
||||
USERLISTAPI_TYPE_FRIENDS,
|
||||
USERLISTAPI_TYPE_BLOCKED,
|
||||
USERLISTAPI_TYPE_FRIENDS_OF_FRIEND,
|
||||
USERLISTAPI_TYPE_MUTED
|
||||
} UserListApiTypeE;
|
||||
|
||||
typedef enum UserListApiIfATypeE
|
||||
{
|
||||
USERLISTAPI_IS_FRIENDS,
|
||||
USERLISTAPI_IS_BLOCKED
|
||||
} UserListApiIfATypeE;
|
||||
|
||||
typedef enum UserListApiReturnTypeE
|
||||
{
|
||||
TYPE_USER_DATA,
|
||||
TYPE_LIST_END
|
||||
} UserListApiReturnTypeE;
|
||||
|
||||
typedef enum UserListApiIsAReturnTypeE
|
||||
{
|
||||
USERLISTAPI_IS_OF_TYPE,
|
||||
USERLISTAPI_IS_NOT_OF_TYPE,
|
||||
USERLISTAPI_IS_MYSELF,
|
||||
USERLISTAPI_IS_TYPE_UNKNOWN
|
||||
} UserListApiIsAReturnTypeE;
|
||||
|
||||
typedef enum UserListApiNotifyTypeE
|
||||
{
|
||||
USERLISTAPI_NOTIFY_FRIENDLIST_UPDATE = 0,
|
||||
USERLISTAPI_NOTIFY_BLOCKEDLIST_UPDATE
|
||||
}
|
||||
UserListApiNotifyTypeE;
|
||||
|
||||
typedef enum UserListApiUpdateTypeE
|
||||
{
|
||||
USERLISTAPI_UPDATE_TYPE_UNKNOWN = 0,
|
||||
USERLISTAPI_UPDATE_TYPE_REMOVED,
|
||||
USERLISTAPI_UPDATE_TYPE_ADD
|
||||
} UserListApiUpdateTypeE;
|
||||
|
||||
/*** Macros ***************************************************************************************/
|
||||
|
||||
/*** Type Definitions *****************************************************************************/
|
||||
|
||||
//!< opaque module ref
|
||||
typedef struct UserListApiRefT UserListApiRefT;
|
||||
|
||||
//!< search filters ref, this will be further defined in platforms specific headers
|
||||
typedef struct UserListApiFiltersT UserListApiFiltersT;
|
||||
|
||||
//!< response structure for user data
|
||||
typedef struct UserListApiUserDataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
uint8_t bIsMutualFriend; // TRUE if the user is a mutual friend, FALSE otherwise
|
||||
uint8_t bIsFavorite; // TRUE if the user is a favorite friend, FALSE otherwise
|
||||
int32_t iUserProfileError; // >= 0 means the profile is valid, otherwise a meaningful error code
|
||||
UserApiUserDataT ExtendedUserData; // user details containing profile, presence and rich presence
|
||||
UserListApiTypeE eRequestType; // type of user lists, friends, recently met, etc
|
||||
uint32_t uUserIndex; // index of local user index
|
||||
UserListApiFiltersT *pUserListFilters; // filters used for this query, first Party Specific, only valid inside the UserListApiCallbackT
|
||||
void *pRawData; // pointer to 1st party friend data
|
||||
} UserListApiUserDataT;
|
||||
|
||||
//!< response structure for metadata
|
||||
typedef struct UserListApiEndDataT
|
||||
{
|
||||
UserListApiTypeE eRequestType; // type of user lists, friends, recently met, etc
|
||||
UserListApiFiltersT *pUserListFilters; // filters used for this query, first Party Specific, only valid inside the UserListApiCallbackT
|
||||
uint32_t uUserIndex; // index of local user index
|
||||
uint32_t uTypeMask; // type mask
|
||||
int64_t iLimit; // maximum number of users to return
|
||||
int64_t iOffset; // index of first user from 1st party query
|
||||
int64_t iTotalFriendCount; // total number of users that match the query, will become valid
|
||||
int32_t Error; // error code returned by the function
|
||||
int32_t iRateLimRetrySecs; // if Error is USERLISTAPI_ERROR_RATE_LIMITED then this is the number of seconds to wait before retrying
|
||||
} UserListApiEndDataT;
|
||||
|
||||
//!< IsA style request response
|
||||
typedef struct UserListApiIsADataT
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
uint32_t uUserIndex; // index of local user index
|
||||
UserListApiIsAReturnTypeE eIsaType; // result (yes, no, unknown or myself)
|
||||
uint8_t bIsMutualFriend; // TRUE if the user is a mutual friend, FALSE otherwise
|
||||
uint8_t bIsFavorite; // TRUE if the user is a favorite friend, FALSE otherwise
|
||||
int32_t Error; // error code returned by the function
|
||||
int32_t iRateLimRetrySecs; // if Error is USERLISTAPI_ERROR_RATE_LIMITED then this is the number of seconds to wait before retrying
|
||||
} UserListApiIsADataT;
|
||||
|
||||
//!< container union for generic response
|
||||
typedef union UserListApiEventDataT
|
||||
{
|
||||
struct UserListApiUserDataT UserData; // user data for eResponseType = TYPE_USER_DATA
|
||||
struct UserListApiEndDataT ListEndData; // meta data for eResponseType = TYPE_LIST_END
|
||||
} UserListApiEventDataT;
|
||||
|
||||
//!< presence update notification data
|
||||
typedef struct UserListApiNotifyPresenceUpdateData
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
} UserListApiNotifyPresenceUpdateData;
|
||||
|
||||
//!< rich presence update notification data
|
||||
typedef struct UserListApiNotifyRichPresenceUpdateData
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
} UserListApiNotifyRichPresenceUpdateData;
|
||||
|
||||
//!< friend list update notification data
|
||||
typedef struct UserListApiNotifyFriendListUpdate
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
UserListApiUpdateTypeE eType;
|
||||
uint32_t uUserIndex; // user index for whom this notification belongs
|
||||
} UserListApiNotifyFriendListUpdate;
|
||||
|
||||
//!< blocked list update notification data
|
||||
typedef struct UserListApiNotifyBlockedListUpdate
|
||||
{
|
||||
DirtyUserT DirtyUser; // user identifier
|
||||
UserListApiUpdateTypeE eType;
|
||||
uint32_t uUserIndex; // user index for whom this notification belongs
|
||||
} UserListApiNotifyBlockedListUpdate;
|
||||
|
||||
|
||||
//!< container union for notification results
|
||||
typedef union UserListApiNotifyDataT
|
||||
{
|
||||
UserListApiNotifyFriendListUpdate FriendListData;
|
||||
UserListApiNotifyBlockedListUpdate BlockedListData;
|
||||
} UserListApiNotifyDataT;
|
||||
|
||||
//<! list query callback
|
||||
typedef void (UserListApiCallbackT)(UserListApiRefT *pRef, UserListApiReturnTypeE eResponseType, UserListApiEventDataT *pUserApiEventData, void *pUserData);
|
||||
|
||||
//<! "is a" query callback
|
||||
typedef void (UserListApiIsAQueryCallbackT)(UserListApiRefT *pRef, UserListApiIfATypeE eResponseType, UserListApiIsADataT *pUserApiEventData, void *pUserData);
|
||||
|
||||
//<! notification callback
|
||||
typedef void (UserListApiUpdateCallbackT)(UserListApiRefT *pRef, UserListApiNotifyTypeE eType, UserListApiNotifyDataT *pData, void *pUserData);
|
||||
|
||||
/*** Variables ************************************************************************************/
|
||||
|
||||
/*** Functions ************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//!< create the user list api object
|
||||
DIRTYCODE_API UserListApiRefT *UserListApiCreate(uint32_t uMaxResponseSize);
|
||||
|
||||
//!< set the callback used for registering userlist update event
|
||||
DIRTYCODE_API int32_t UserListApiRegisterUpdateEvent(UserListApiRefT *pRef, uint32_t uUserIndex, UserListApiNotifyTypeE eType, UserListApiUpdateCallbackT *pNotifyCb, void *pUserData);
|
||||
|
||||
//!< give module time to perform periodic processing
|
||||
DIRTYCODE_API void UserListApiUpdate(UserListApiRefT *pRef);
|
||||
|
||||
//!< get status information
|
||||
DIRTYCODE_API int32_t UserListApiStatus(UserListApiRefT *pRef, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
//!< control function
|
||||
DIRTYCODE_API int32_t UserListApiControl(UserListApiRefT *pRef, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
//!< destroy the user list api object
|
||||
DIRTYCODE_API void UserListApiDestroy(UserListApiRefT *pRef);
|
||||
|
||||
//!< gets the list of users of the specified type
|
||||
DIRTYCODE_API int32_t UserListApiGetListAsync(UserListApiRefT *pRef, uint32_t uUserIndex, UserListApiTypeE eType, int32_t iLimit, int32_t iOffset, UserListApiFiltersT *filter, UserListApiCallbackT *pNotifyCb, uint32_t uTypeMask, void *pUserData);
|
||||
|
||||
//!< Is target user a friend
|
||||
DIRTYCODE_API int32_t UserListApiIsFriendAsync(UserListApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pUser, UserListApiIsAQueryCallbackT *pNotifyCb, void *pUserData);
|
||||
|
||||
//!< Is target user blocked
|
||||
DIRTYCODE_API int32_t UserListApiIsBlockedAsync(UserListApiRefT *pRef, uint32_t uUserIndex, DirtyUserT *pUser, UserListApiIsAQueryCallbackT *pNotifyCb, void *pUserData);
|
||||
|
||||
//!< cancels all pending transactions
|
||||
DIRTYCODE_API void UserListApiCancelAll(UserListApiRefT *pRef);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _userlistapi_h
|
||||
|
81
src/thirdparty/dirtysdk/include/DirtySDK/misc/weblog.h
vendored
Normal file
81
src/thirdparty/dirtysdk/include/DirtySDK/misc/weblog.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File weblog.h
|
||||
|
||||
\Description
|
||||
Captures DirtySDK debug output and posts it to a webserver where the output
|
||||
can be retrieved. This is useful when debugging on a system with no
|
||||
debugging capability or in a "clean room" environment, for example.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2008 Electronic Arts Inc.
|
||||
|
||||
\Version 05/06/2008 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _weblog_h
|
||||
#define _weblog_h
|
||||
|
||||
/*!
|
||||
\Moduledef WebLog WebLog
|
||||
\Modulemember Misc
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct WebLogRefT WebLogRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module
|
||||
DIRTYCODE_API WebLogRefT *WebLogCreate(int32_t iBufSize);
|
||||
|
||||
// configure the module
|
||||
DIRTYCODE_API void WebLogConfigure(WebLogRefT *pWebLog, const char *pServer, const char *pUrl);
|
||||
|
||||
// start web log logging
|
||||
DIRTYCODE_API void WebLogStart(WebLogRefT *pWebLog);
|
||||
|
||||
// stop web log logging
|
||||
DIRTYCODE_API void WebLogStop(WebLogRefT *pWebLog);
|
||||
|
||||
// destroy the module
|
||||
DIRTYCODE_API void WebLogDestroy(WebLogRefT *pWebLog);
|
||||
|
||||
// weblog netprintf hook
|
||||
DIRTYCODE_API int32_t WebLogDebugHook(void *pUserData, const char *pText);
|
||||
|
||||
// print to weblog buffer
|
||||
DIRTYCODE_API void WebLogPrintf(WebLogRefT *pWebLog, const char *pFormat, ...);
|
||||
|
||||
// control weblog behavior
|
||||
DIRTYCODE_API int32_t WebLogControl(WebLogRefT *pWebLog, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// update the weblog module
|
||||
DIRTYCODE_API void WebLogUpdate(WebLogRefT *pWebLog);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _weblog_h
|
||||
|
240
src/thirdparty/dirtysdk/include/DirtySDK/platform.h
vendored
Normal file
240
src/thirdparty/dirtysdk/include/DirtySDK/platform.h
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File platform.h
|
||||
|
||||
\Description
|
||||
A platform wide header that performs environment identification and replaces
|
||||
some standard lib functions with "safe" alternatives (such an snprintf that
|
||||
always terminates the buffer).
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 01/25/2005 (gschaefer) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _platform_h
|
||||
#define _platform_h
|
||||
|
||||
/*!
|
||||
\Moduledef Platform Platform
|
||||
\Modulemember DirtySock
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include <EABase/eabase.h>
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// identify platform if not yet known
|
||||
#if defined(DIRTYCODE_PC) || defined(DIRTYCODE_LINUX)
|
||||
// do nothing
|
||||
#elif defined(EA_PLATFORM_XBSX)
|
||||
#define DIRTYCODE_GDK 1
|
||||
#define DIRTYCODE_XBSX 1
|
||||
#elif defined(EA_PLATFORM_XBOX_GDK)
|
||||
#define DIRTYCODE_GDK 1
|
||||
#define DIRTYCODE_XBOXONE 1
|
||||
#elif defined(EA_PLATFORM_CAPILANO)
|
||||
#define DIRTYCODE_XBOXONE 1
|
||||
#elif defined(EA_PLATFORM_MICROSOFT)
|
||||
#define DIRTYCODE_PC 1
|
||||
#elif defined(EA_PLATFORM_PS4)
|
||||
#define DIRTYCODE_PS4 1
|
||||
#elif defined(EA_PLATFORM_PS5)
|
||||
#define DIRTYCODE_PS5 1
|
||||
#define DIRTYCODE_PS4 1
|
||||
#elif defined(EA_PLATFORM_IPHONE) || defined(EA_PLATFORM_IPHONE_SIMULATOR)
|
||||
#define DIRTYCODE_APPLEIOS 1
|
||||
#elif defined(EA_PLATFORM_OSX)
|
||||
#define DIRTYCODE_APPLEOSX 1
|
||||
#elif defined(EA_PLATFORM_ANDROID)
|
||||
#define DIRTYCODE_ANDROID 1
|
||||
#elif defined(EA_PLATFORM_STADIA)
|
||||
#define DIRTYCODE_LINUX 1
|
||||
#define DIRTYCODE_STADIA 1
|
||||
#elif defined(EA_PLATFORM_LINUX)
|
||||
#define DIRTYCODE_LINUX 1
|
||||
#elif defined(EA_PLATFORM_NX)
|
||||
#define DIRTYCODE_NX 1
|
||||
#endif
|
||||
|
||||
// define platform name
|
||||
#if defined(DIRTYCODE_ANDROID)
|
||||
#define DIRTYCODE_PLATNAME "Android"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "android"
|
||||
#elif defined(DIRTYCODE_APPLEIOS)
|
||||
#define DIRTYCODE_PLATNAME "AppleIOS"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "ios"
|
||||
#elif defined(DIRTYCODE_APPLEOSX)
|
||||
#define DIRTYCODE_PLATNAME "AppleOSX"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "osx"
|
||||
#elif defined(DIRTYCODE_XBSX)
|
||||
#define DIRTYCODE_PLATNAME "XboxSeriesX"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "xbsx"
|
||||
#elif defined(DIRTYCODE_XBOXONE)
|
||||
#define DIRTYCODE_PLATNAME "XboxOne"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "xone"
|
||||
#elif defined(DIRTYCODE_PS5)
|
||||
#define DIRTYCODE_PLATNAME "PlayStation5"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "ps5"
|
||||
#elif defined(DIRTYCODE_PS4)
|
||||
#define DIRTYCODE_PLATNAME "PlayStation4"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "ps4"
|
||||
#elif defined(DIRTYCODE_STADIA)
|
||||
#define DIRTYCODE_PLATNAME "Stadia"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "stadia"
|
||||
#elif defined(DIRTYCODE_LINUX)
|
||||
#define DIRTYCODE_PLATNAME "Linux"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "linux"
|
||||
#elif defined(DIRTYCODE_PC)
|
||||
#define DIRTYCODE_PLATNAME "Windows"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "pc"
|
||||
#elif defined(DIRTYCODE_NX)
|
||||
#define DIRTYCODE_PLATNAME "Switch"
|
||||
#define DIRTYCODE_PLATNAME_SHORT "nx"
|
||||
#else
|
||||
#error The platform was not predefined and could not be auto-determined!
|
||||
#endif
|
||||
|
||||
//For Building as a dll
|
||||
#if defined(EA_DLL)
|
||||
#ifndef DIRTYCODE_DLL
|
||||
#define DIRTYCODE_DLL
|
||||
#endif
|
||||
#ifndef DIRTYCODE_API
|
||||
#define DIRTYCODE_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DIRTYCODE_API
|
||||
#endif
|
||||
|
||||
// define 32-bit or 64-bit pointers
|
||||
#if (EA_PLATFORM_PTR_SIZE == 8)
|
||||
#define DIRTYCODE_64BITPTR (1)
|
||||
#else
|
||||
#define DIRTYCODE_64BITPTR (0)
|
||||
#endif
|
||||
|
||||
// we need va_list to be a universal type
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
#include <time.h>
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// force our definition of TRUE/FALSE
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#endif
|
||||
|
||||
#define FALSE (0)
|
||||
#define TRUE (1)
|
||||
|
||||
// map common debug code definitions to our debug code definition
|
||||
#ifndef DIRTYCODE_DEBUG
|
||||
#if defined(EA_DEBUG)
|
||||
#define DIRTYCODE_DEBUG (1)
|
||||
#else
|
||||
#define DIRTYCODE_DEBUG (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
//! min of _x and _y
|
||||
#define DS_MIN(_x, _y) (((_x) < (_y)) ? (_x) : (_y))
|
||||
|
||||
//! max of _x and _y
|
||||
#define DS_MAX(_x, _y) (((_x) > (_y)) ? (_x) : (_y))
|
||||
|
||||
//! abs of _x
|
||||
#define DS_ABS(_x) (((_x) < 0) ? -(_x) : (_x))
|
||||
|
||||
//! clamp _x between _min and _max; if _low < _high result is undefined
|
||||
#define DS_CLAMP(_x, _min, _max) (((_x) > (_max)) ? (_max) : (((_x) < (_min)) ? (_min) : (_x)))
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! time-to-string conversion type
|
||||
typedef enum TimeToStringConversionTypeE
|
||||
{
|
||||
TIMETOSTRING_CONVERSION_ISO_8601, //!< ISO 8601 standard: yyyy-MM-ddTHH:mmZ where Z means 0 UTC offset, and no Z means local time zone
|
||||
TIMETOSTRING_CONVERSION_ISO_8601_BASIC, //!< ISO 8601 basic format (no hyphens or colon) : https://en.wikipedia.org/wiki/ISO_8601#cite_ref-15
|
||||
TIMETOSTRING_CONVERSION_RFC_0822, //!< RFC 0822 format, updated by RFC1123: day, dd mon yyyy hh:mm:ss zzz
|
||||
TIMETOSTRING_CONVERSION_ASN1_UTCTIME, //!< ASN.1 UTCTime format
|
||||
TIMETOSTRING_CONVERSION_ASN1_GENTIME, //!< ASN.1 GeneralizedTime format
|
||||
TIMETOSTRING_CONVERSION_UNKNOWN //!< unknown source format type; try to auto-determine if possible
|
||||
} TimeToStringConversionTypeE;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// replacement time functions
|
||||
DIRTYCODE_API uint64_t ds_timeinsecs(void);
|
||||
DIRTYCODE_API int32_t ds_timezone(void);
|
||||
DIRTYCODE_API struct tm *ds_localtime(struct tm *pTm, uint64_t elap);
|
||||
DIRTYCODE_API struct tm *ds_secstotime(struct tm *pTm, uint64_t elap);
|
||||
DIRTYCODE_API uint64_t ds_timetosecs(const struct tm *pTm);
|
||||
DIRTYCODE_API struct tm *ds_plattimetotime(struct tm *pTm, void *pPlatTime);
|
||||
DIRTYCODE_API struct tm *ds_plattimetotimems(struct tm *pTm, int32_t *pImSec);
|
||||
DIRTYCODE_API char *ds_timetostr(const struct tm *pTm, TimeToStringConversionTypeE eConvType, uint8_t bLocalTime, char *pStr, int32_t iBufSize);
|
||||
DIRTYCODE_API char *ds_secstostr(uint64_t elap, TimeToStringConversionTypeE eConvType, uint8_t bLocalTime, char *pStr, int32_t iBufSize);
|
||||
DIRTYCODE_API uint64_t ds_strtotime(const char *str);
|
||||
DIRTYCODE_API uint64_t ds_strtotime2(const char *pStr, TimeToStringConversionTypeE eConvType);
|
||||
|
||||
// replacement string functions
|
||||
DIRTYCODE_API int32_t ds_strnlen(const char *pBuffer, int32_t iLength);
|
||||
DIRTYCODE_API int32_t ds_vsnprintf(char *pBuffer, int32_t iLength, const char *pFormat, va_list Args);
|
||||
DIRTYCODE_API int32_t ds_vsnzprintf(char *pBuffer, int32_t iLength, const char *pFormat, va_list Args);
|
||||
DIRTYCODE_API int32_t ds_snzprintf(char *pBuffer, int32_t iLength, const char *pFormat, ...);
|
||||
DIRTYCODE_API char *ds_strnzcpy(char *pDest, const char *pSource, int32_t iCount);
|
||||
DIRTYCODE_API int32_t ds_strnzcat(char *pDst, const char *pSrc, int32_t iDstLen);
|
||||
DIRTYCODE_API int32_t ds_stricmp(const char *pString1, const char *pString2);
|
||||
DIRTYCODE_API int32_t ds_strnicmp(const char *pString1, const char *pString2, uint32_t uCount);
|
||||
DIRTYCODE_API char *ds_stristr(const char *pHaystack, const char *pNeedle);
|
||||
DIRTYCODE_API char* ds_strtok_r(char *pStr, const char *pDelim, char **ppSavePtr);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define ds_strtoll(_buf, _outp, _radix) _strtoi64(_buf, _outp, _radix)
|
||||
#define ds_strtoull(_buf, _outp, _radix) _strtoui64(_buf, _outp, _radix)
|
||||
#else
|
||||
#define ds_strtoll(_buf, _outp, _radix) strtoll(_buf, _outp, _radix)
|
||||
#define ds_strtoull(_buf, _outp, _radix) strtoull(_buf, _outp, _radix)
|
||||
#endif
|
||||
|
||||
// 'original' string functions
|
||||
DIRTYCODE_API char *ds_fmtoctstring(char *pOutput, int32_t iOutLen, const uint8_t *pInput, int32_t iInpLen);
|
||||
DIRTYCODE_API char *ds_fmtoctstring_lc(char *pOutput, int32_t iOutLen, const uint8_t *pInput, int32_t iInpLen);
|
||||
DIRTYCODE_API char *ds_strtolower(char *pString);
|
||||
DIRTYCODE_API char *ds_strtoupper(char *pString);
|
||||
DIRTYCODE_API char *ds_strtrim(char *pString);
|
||||
DIRTYCODE_API int32_t ds_strlistinsert(char *pStrList, int32_t iListBufLen, const char *pString, char cTerm);
|
||||
DIRTYCODE_API int32_t ds_strsubzcpy(char *pDst, int32_t iDstLen, const char *pSrc, int32_t iSrcLen);
|
||||
DIRTYCODE_API int32_t ds_strsubzcat(char *pDst, int32_t iDstLen, const char *pSrc, int32_t iSrcLen);
|
||||
DIRTYCODE_API int32_t ds_strcmpwc(const char *pString1, const char *pStrWild);
|
||||
DIRTYCODE_API int32_t ds_stricmpwc(const char *pString1, const char *pStrWild);
|
||||
DIRTYCODE_API int32_t ds_strsplit(const char *pSrc, char cDelimiter, char *pDst, int32_t iDstSize, const char **pNewSrc);
|
||||
|
||||
// mem functions
|
||||
DIRTYCODE_API void ds_memcpy(void *pDst, const void *pSrc, int32_t iDstLen);
|
||||
DIRTYCODE_API void ds_memcpy_s(void *pDst, int32_t iDstLen, const void *pSrc, int32_t iSrcLen);
|
||||
DIRTYCODE_API void ds_memclr(void *pMem, int32_t iCount);
|
||||
DIRTYCODE_API void ds_memset(void *pMem, int32_t iValue, int32_t iCount);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _platform_h
|
99
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoadvt.h
vendored
Normal file
99
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoadvt.h
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File protoadvt.h
|
||||
|
||||
\Description
|
||||
This advertising module provides a relatively simple multi-protocol
|
||||
distributed name server architecture utilizing the broadcast capabilities
|
||||
of UDP and IPX. Once the module is instantiated, it can be used as both
|
||||
an advertiser (server) and watcher (client) simultaneously.
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2002. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 02/17/99 (GWS) Original version
|
||||
\Version 1.1 02/25/99 (GWS) Alpha release
|
||||
\Version 1.2 08/10/99 (GWS) Final release
|
||||
\Version 1.3 12/04/00 (GWS) Revised for Dirtysock
|
||||
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _protoadvt_h
|
||||
#define _protoadvt_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoAdvt ProtoAdvt
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! define the ports used for service broadcasts
|
||||
#define ADVERT_BROADCAST_PORT_UDP 9999
|
||||
#define ADVERT_BROADCAST_PORT_IPX 9999
|
||||
|
||||
//! define the static packet header identifier
|
||||
#define ADVERT_PACKET_IDENTIFIER "gEA"
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! module reference -- passed as first arg to all module functions
|
||||
typedef struct ProtoAdvtRef ProtoAdvtRef;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct an advertising agent
|
||||
DIRTYCODE_API ProtoAdvtRef *ProtoAdvtConstruct(int32_t buffer);
|
||||
|
||||
// destruct an advertising agent
|
||||
DIRTYCODE_API void ProtoAdvtDestroy(ProtoAdvtRef *what);
|
||||
|
||||
// query for available services
|
||||
DIRTYCODE_API int32_t ProtoAdvtQuery(ProtoAdvtRef *what, const char *kind, const char *proto,
|
||||
char *buffer, int32_t buflen, int32_t local);
|
||||
|
||||
// locate a specific advertisement and return advertisers address (UDP only)
|
||||
DIRTYCODE_API uint32_t ProtoAdvtLocate(ProtoAdvtRef *ref, const char *kind, const char *name,
|
||||
uint32_t *host, uint32_t defval);
|
||||
|
||||
// advertise a service as available
|
||||
DIRTYCODE_API int32_t ProtoAdvtAnnounce(ProtoAdvtRef *what, const char *kind, const char *name,
|
||||
const char *addr, const char *note, int32_t freq);
|
||||
|
||||
// cancel server advertisement
|
||||
DIRTYCODE_API int32_t ProtoAdvtCancel(ProtoAdvtRef *what, const char *kind, const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protoadvt_h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
229
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttp.h
vendored
Normal file
229
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttp.h
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protohttp.h
|
||||
|
||||
\Description
|
||||
This module implements an HTTP client that can perform basic transactions
|
||||
(get/put) with an HTTP server. It conforms to but does not fully implement
|
||||
the 1.1 HTTP spec (http://www.w3.org/Protocols/rfc2616/rfc2616.html), and
|
||||
allows for secure HTTP transactions as well as insecure transactions.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2000-2018. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 0.5 02/21/2000 (gschaefer) First Version
|
||||
\Version 1.0 12/07/2000 (gschaefer) Added PS2/Dirtysock support
|
||||
\Version 1.1 03/03/2004 (sbevan) ProtoSSL/https rewrite, added limited Post support.
|
||||
\Version 1.2 11/18/2004 (jbrookes) Refactored, updated to HTTP 1.1, added full Post support.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protohttp_h
|
||||
#define _protohttp_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoHttp ProtoHttp
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protohttputil.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// defines for ProtoHttpPost's bDoPut parameter
|
||||
#define PROTOHTTP_POST (0) //!< execute a POST when calling ProtoHttpPost
|
||||
#define PROTOHTTP_PUT (1) //!< execute a PUT when calling ProtoHttpPost
|
||||
|
||||
// define for ProtoHttpPost's iDataSize parameter
|
||||
#define PROTOHTTP_STREAM_BEGIN (-1) //!< start streaming upload (size unknown)
|
||||
|
||||
// define for ProtoHttpSend's iDataSize parameter
|
||||
#define PROTOHTTP_STREAM_END (0) //!< streaming upload operation is complete
|
||||
|
||||
// defines for ProtoHttpGet's bHeadOnly parameter
|
||||
#define PROTOHTTP_HEADBODY (0) //!< get head and body when calling ProtoHttpGet
|
||||
#define PROTOHTTP_HEADONLY (1) //!< only get head, not body, when calling ProtoHttpGet
|
||||
|
||||
// defines for ProtoHttpRecv's return result
|
||||
#define PROTOHTTP_RECVDONE (-1) //!< receive operation complete, and all data has been read
|
||||
#define PROTOHTTP_RECVFAIL (-2) //!< receive operation failed
|
||||
#define PROTOHTTP_RECVWAIT (-3) //!< waiting for body data
|
||||
#define PROTOHTTP_RECVHEAD (-4) //!< in headonly mode and header has been received
|
||||
#define PROTOHTTP_RECVBUFF (-5) //!< recvall did not have enough space in the provided buffer
|
||||
#define PROTOHTTP_RECVRDIR (-6) //!< maximum number of redirects exceeded
|
||||
|
||||
// generic protohttp errors (do not overlap with RECV* codes)
|
||||
#define PROTOHTTP_MINBUFF (-16) //!< not enough input buffer space for operation
|
||||
#define PROTOHTTP_TIMEOUT (-17) //!< did not receive response from server in configured time
|
||||
|
||||
#define PROTOHTTP_NOTHREADS (-18) //!< not enough worker threads can be spawned (deprecated)
|
||||
#define PROTOHTTP_EAGAIN (-18) //!< resource not available
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtoHttpRefT ProtoHttpRefT;
|
||||
|
||||
//! write callback info
|
||||
#ifndef _PROTOHTTP_WRITECBINFO_DEFINED
|
||||
typedef struct ProtoHttpWriteCbInfoT
|
||||
{
|
||||
ProtoHttpRequestTypeE eRequestType;
|
||||
ProtoHttpResponseE eRequestResponse;
|
||||
} ProtoHttpWriteCbInfoT;
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpWriteCbT
|
||||
|
||||
\Description
|
||||
Write data callback
|
||||
|
||||
\Input *pState - module state
|
||||
\Input *pCbInfo - information about about the request this data is for
|
||||
\Input *pData - data we received from the server
|
||||
\Input iDataSize - size of the data
|
||||
\Input *pUserData - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - unused
|
||||
*/
|
||||
typedef int32_t (ProtoHttpWriteCbT)(ProtoHttpRefT *pState, const ProtoHttpWriteCbInfoT *pCbInfo, const char *pData, int32_t iDataSize, void *pUserData);
|
||||
|
||||
#define _PROTOHTTP_WRITECBINFO_DEFINED
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpCustomHeaderCbT
|
||||
|
||||
\Description
|
||||
Callback that may be used to customize request header before sending
|
||||
|
||||
\Input *pState - module state
|
||||
\Input *pHeader - [out] request headers that we are going to send
|
||||
\Input uHeaderSize - size of the request headers
|
||||
\Input *pData - pointer to data sent in the request. deprecated, will always be NULL
|
||||
\Input iDataLen - size of the data sent in the request. deprecated, will always be 0
|
||||
\Input *pUserRef - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - negative=error, size of the header=success
|
||||
|
||||
\Deprecated
|
||||
pData and iDataLen are deprecated. We will pass NULL and 0 to them respectively.
|
||||
*/
|
||||
typedef int32_t (ProtoHttpCustomHeaderCbT)(ProtoHttpRefT *pState, char *pHeader, uint32_t uHeaderSize, const char *pData, int64_t iDataLen, void *pUserRef);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpReceiveHeaderCbT
|
||||
|
||||
\Description
|
||||
Callback that may be used to implement custom header parsing on header receipt
|
||||
|
||||
\Input *pState - module state
|
||||
\Input *pHeader - header we received from the server
|
||||
\Input uHeaderSize - size of the response header
|
||||
\Input *pUserRef - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - unused
|
||||
*/
|
||||
//! callback that may be used to implement custom header parsing on header receipt
|
||||
typedef int32_t (ProtoHttpReceiveHeaderCbT)(ProtoHttpRefT *pState, const char *pHeader, uint32_t uHeaderSize, void *pUserRef);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate module state and prepare for use
|
||||
DIRTYCODE_API ProtoHttpRefT *ProtoHttpCreate(int32_t iRcvBuf);
|
||||
|
||||
// set custom header callback
|
||||
DIRTYCODE_API void ProtoHttpCallback(ProtoHttpRefT *pState, ProtoHttpCustomHeaderCbT *pCustomHeaderCb, ProtoHttpReceiveHeaderCbT *pReceiveHeaderCb, void *pUserRef);
|
||||
|
||||
// destroy the module and release its state
|
||||
DIRTYCODE_API void ProtoHttpDestroy(ProtoHttpRefT *pState);
|
||||
|
||||
// initiate an HTTP transfer
|
||||
DIRTYCODE_API int32_t ProtoHttpGet(ProtoHttpRefT *pState, const char *pUrl, uint32_t bHeadOnly);
|
||||
|
||||
// return the actual url data
|
||||
DIRTYCODE_API int32_t ProtoHttpRecv(ProtoHttpRefT *pState, char *pBuffer, int32_t iBufMin, int32_t iBufMax);
|
||||
|
||||
// receive all of the response data
|
||||
DIRTYCODE_API int32_t ProtoHttpRecvAll(ProtoHttpRefT *pState, char *pBuffer, int32_t iBufSize);
|
||||
|
||||
// initiate transfer of data to to the server via an HTTP POST command
|
||||
DIRTYCODE_API int32_t ProtoHttpPost(ProtoHttpRefT *pState, const char *pUrl, const char *pData, int64_t iDataSize, uint32_t bDoPut);
|
||||
|
||||
// send the actual url data
|
||||
DIRTYCODE_API int32_t ProtoHttpSend(ProtoHttpRefT *pState, const char *pData, int32_t iDataSize);
|
||||
|
||||
// request deletion of a server-based resource
|
||||
DIRTYCODE_API int32_t ProtoHttpDelete(ProtoHttpRefT *pState, const char *pUrl);
|
||||
|
||||
// get server options for specified resource
|
||||
DIRTYCODE_API int32_t ProtoHttpOptions(ProtoHttpRefT *pState, const char *pUrl);
|
||||
|
||||
// initiate transfer of data to to the server via an HTTP PATCH command
|
||||
DIRTYCODE_API int32_t ProtoHttpPatch(ProtoHttpRefT *pState, const char *pUrl, const char *pData, int64_t iDataSize);
|
||||
|
||||
// make an HTTP request
|
||||
#define ProtoHttpRequest(_pState, _pUrl, _pData, _iDataSize, _eRequestType) ProtoHttpRequestCb2(_pState, _pUrl, _pData, _iDataSize, _eRequestType, NULL, NULL, NULL, NULL)
|
||||
|
||||
// make an HTTP request with write callback
|
||||
#define ProtoHttpRequestCb(_pState, _pUrl, _pData, _iDataSize, _eRequestType, _pWriteCb, _pWriteCbUserData) ProtoHttpRequestCb2(_pState, _pUrl, _pData, _iDataSize, _eRequestType, _pWriteCb, NULL, NULL, _pWriteCbUserData)
|
||||
|
||||
// make an HTTP request with write, custom header and receive header callback
|
||||
DIRTYCODE_API int32_t ProtoHttpRequestCb2(ProtoHttpRefT *pState, const char *pUrl, const char *pData, int64_t iDataSize, ProtoHttpRequestTypeE eRequestType, ProtoHttpWriteCbT *pWriteCb, ProtoHttpCustomHeaderCbT *pCustomHeaderCb, ProtoHttpReceiveHeaderCbT *pReceiveHeaderCb, void *pUserData);
|
||||
|
||||
// abort current transaction
|
||||
DIRTYCODE_API void ProtoHttpAbort(ProtoHttpRefT *pState);
|
||||
|
||||
// set base url (used in relative url support)
|
||||
DIRTYCODE_API void ProtoHttpSetBaseUrl(ProtoHttpRefT *pState, const char *pUrl);
|
||||
|
||||
// get location header (requires state and special processing for relative urls)
|
||||
DIRTYCODE_API int32_t ProtoHttpGetLocationHeader(ProtoHttpRefT *pState, const char *pInpBuf, char *pBuffer, int32_t iBufSize, const char **pHdrEnd);
|
||||
|
||||
// control function; functionality based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttpControl(ProtoHttpRefT *pState, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// return module status based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttpStatus(ProtoHttpRefT *pState, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// check whether a request for the given Url would be a keep-alive transaction
|
||||
DIRTYCODE_API int32_t ProtoHttpCheckKeepAlive(ProtoHttpRefT *pState, const char *pUrl);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
DIRTYCODE_API void ProtoHttpUpdate(ProtoHttpRefT *pState);
|
||||
|
||||
// add an X.509 CA certificate that will be recognized in future transactions
|
||||
DIRTYCODE_API int32_t ProtoHttpSetCACert(const uint8_t *pCACert, int32_t iCertSize);
|
||||
|
||||
// same as ProtoHttpSetCACert(), but .pem certificates multiply bundled are parsed bottom to top
|
||||
DIRTYCODE_API int32_t ProtoHttpSetCACert2(const uint8_t *pCACert, int32_t iCertSize);
|
||||
|
||||
// validate all CAs that have not already been validated
|
||||
DIRTYCODE_API int32_t ProtoHttpValidateAllCA(void);
|
||||
|
||||
// clear all CA certs
|
||||
DIRTYCODE_API void ProtoHttpClrCACerts(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protohttp_h
|
||||
|
193
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttp2.h
vendored
Normal file
193
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttp2.h
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protohttp2.h
|
||||
|
||||
\Description
|
||||
This module implements an HTTP/2 client that can perform basic transactions
|
||||
with an HTTP/2 server. It conforms to but does not fully implement
|
||||
the 2.0 HTTP spec (https://tools.ietf.org/html/rfc7540), and
|
||||
allows for secure HTTP transactions as well as insecure transactions.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2016-2018. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protohttp2_h
|
||||
#define _protohttp2_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoHttp2 ProtoHttp2
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protohttputil.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// define for ProtoHttp2Request iDataSize parameter
|
||||
#define PROTOHTTP2_STREAM_BEGIN (-1) //!< start streaming upload (size unknown)
|
||||
|
||||
// define for ProtoHttp2Send's iDataSize parameter
|
||||
#define PROTOHTTP2_STREAM_END (0) //!< streaming upload operation is complete
|
||||
|
||||
// define for ProtoHttp2Status/ProtoHttp2Control iStreamId parameter
|
||||
#define PROTOHTTP2_INVALID_STREAMID (-1) //!< invalid stream for the functions that allow for invalid
|
||||
|
||||
// defines for ProtoHttpRecv's return result
|
||||
#define PROTOHTTP2_RECVDONE (-1) //!< receive operation complete, and all data has been read
|
||||
#define PROTOHTTP2_RECVFAIL (-2) //!< receive operation failed
|
||||
#define PROTOHTTP2_RECVWAIT (-3) //!< waiting for body data
|
||||
#define PROTOHTTP2_RECVHEAD (-4) //!< in headonly mode and header has been received
|
||||
#define PROTOHTTP2_RECVBUFF (-5) //!< recvall did not have enough space in the provided buffer
|
||||
|
||||
// generic protohttp errors (do not overlap with RECV* codes)
|
||||
#define PROTOHTTP2_MINBUFF (-6) //!< not enough input buffer space for operation
|
||||
#define PROTOHTTP2_TIMEOUT (-7) //!< did not receive response from server in configured time
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtoHttp2RefT ProtoHttp2RefT;
|
||||
|
||||
//! write callback info
|
||||
typedef struct ProtoHttp2WriteCbInfoT
|
||||
{
|
||||
ProtoHttpRequestTypeE eRequestType;
|
||||
ProtoHttpResponseE eRequestResponse;
|
||||
int32_t iStreamId;
|
||||
} ProtoHttp2WriteCbInfoT;
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttp2WriteCbT
|
||||
|
||||
\Description
|
||||
Write data callback
|
||||
|
||||
\Input *pState - module state
|
||||
\Input *pCbInfo - information about about the request this data is for
|
||||
\Input *pData - data we received from the server
|
||||
\Input iDataSize - size of the data
|
||||
\Input *pUserData - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - unused
|
||||
*/
|
||||
typedef int32_t (ProtoHttp2WriteCbT)(ProtoHttp2RefT *pState, const ProtoHttp2WriteCbInfoT *pCbInfo, const uint8_t *pData, int32_t iDataSize, void *pUserData);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttp2CustomHeaderCbT
|
||||
|
||||
\Description
|
||||
Callback that may be used to customize request header before sending
|
||||
|
||||
\Input *pState - module state
|
||||
\Input *pHeader - [out] request headers that we are going to send
|
||||
\Input uHeaderSize - size of the request headers
|
||||
\Input *pData - pointer to data sent in the request. deprecated, will always be NULL
|
||||
\Input iDataLen - size of the data sent in the request. deprecated, will always be 0
|
||||
\Input *pUserData - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - negative=error, size of the header=success
|
||||
|
||||
\Deprecated
|
||||
pData and iDataLen are deprecated. We will pass NULL and 0 to them respectively.
|
||||
*/
|
||||
typedef int32_t (ProtoHttp2CustomHeaderCbT)(ProtoHttp2RefT *pState, char *pHeader, uint32_t uHeaderSize, const uint8_t *pData, int64_t iDataLen, void *pUserData);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttp2ReceiveHeaderCbT
|
||||
|
||||
\Description
|
||||
Callback that may be used to implement custom header parsing on header receipt
|
||||
|
||||
\Input *pState - module state
|
||||
\Input iStreamId - stream identifier for request
|
||||
\Input *pHeader - header we received from the server
|
||||
\Input uHeaderSize - size of the response header
|
||||
\Input *pUserData - user data pointer passed along in the callback
|
||||
|
||||
\Output
|
||||
int32_t - unused
|
||||
*/
|
||||
typedef int32_t (ProtoHttp2ReceiveHeaderCbT)(ProtoHttp2RefT *pState, int32_t iStreamId, const char *pHeader, uint32_t uHeaderSize, void *pUserData);
|
||||
|
||||
//! state of the stream (see https://tools.ietf.org/html/rfc7540#section-5.1 for reference)
|
||||
typedef enum ProtoHttp2StreamStateE
|
||||
{
|
||||
STREAMSTATE_IDLE,
|
||||
STREAMSTATE_OPEN,
|
||||
STREAMSTATE_HALF_CLOSED_LOCAL,
|
||||
STREAMSTATE_HALF_CLOSED_REMOTE,
|
||||
STREAMSTATE_CLOSED
|
||||
} ProtoHttp2StreamStateE;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate the module state and prepare for use
|
||||
DIRTYCODE_API ProtoHttp2RefT *ProtoHttp2Create(int32_t iRecvBuf);
|
||||
|
||||
// give time to module to do its thing
|
||||
DIRTYCODE_API void ProtoHttp2Update(ProtoHttp2RefT *pState);
|
||||
|
||||
// destroy the module and release its state
|
||||
DIRTYCODE_API void ProtoHttp2Destroy(ProtoHttp2RefT *pState);
|
||||
|
||||
// set the custom header callbacks
|
||||
DIRTYCODE_API void ProtoHttp2Callback(ProtoHttp2RefT *pState, ProtoHttp2CustomHeaderCbT *pCustomHeaderCb, ProtoHttp2ReceiveHeaderCbT *pReceiveHeaderCb, void *pUserData);
|
||||
|
||||
// initiate an HTTP request
|
||||
DIRTYCODE_API int32_t ProtoHttp2Request(ProtoHttp2RefT *pState, const char *pUrl, const uint8_t *pData, int32_t iDataSize, ProtoHttpRequestTypeE eRequestType, int32_t *pStreamId);
|
||||
|
||||
// initiate an HTTP request with a write callback
|
||||
DIRTYCODE_API int32_t ProtoHttp2RequestCb(ProtoHttp2RefT *pState, const char *pUrl, const uint8_t *pData, int32_t iDataSize, ProtoHttpRequestTypeE eRequestType, int32_t *pStreamId, ProtoHttp2WriteCbT *pWriteCb, void *pUserData);
|
||||
|
||||
// initiate an HTTP request with a write, custom header and receive header callback
|
||||
DIRTYCODE_API int32_t ProtoHttp2RequestCb2(ProtoHttp2RefT *pState, const char *pUrl, const uint8_t *pData, int32_t iDataSize, ProtoHttpRequestTypeE eRequestType, int32_t *pStreamId, ProtoHttp2WriteCbT *pWriteCb, ProtoHttp2CustomHeaderCbT *pCustomHeaderCb, ProtoHttp2ReceiveHeaderCbT *pReceiveHeaderCb, void *pUserData);
|
||||
|
||||
// send data for a specific stream, NULL data ends the stream
|
||||
DIRTYCODE_API int32_t ProtoHttp2Send(ProtoHttp2RefT *pState, int32_t iStreamId, const uint8_t *pData, int32_t iDataSize);
|
||||
|
||||
// receive the actual url data
|
||||
DIRTYCODE_API int32_t ProtoHttp2Recv(ProtoHttp2RefT *pState, int32_t iStreamId, uint8_t *pBuffer, int32_t iBufMin, int32_t iBufMax);
|
||||
|
||||
// receive all of the response data for the given stream
|
||||
DIRTYCODE_API int32_t ProtoHttp2RecvAll(ProtoHttp2RefT *pState, int32_t iStreamId, uint8_t *pBuffer, int32_t iBufSize);
|
||||
|
||||
// abort the passed in stream's transaction
|
||||
DIRTYCODE_API void ProtoHttp2Abort(ProtoHttp2RefT *pState, int32_t iStreamId);
|
||||
|
||||
// close the connection to the server
|
||||
DIRTYCODE_API void ProtoHttp2Close(ProtoHttp2RefT *pState);
|
||||
|
||||
// return module status based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttp2Status(ProtoHttp2RefT *pState, int32_t iStreamId, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// control function; functionality based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttp2Control(ProtoHttp2RefT *pState, int32_t iStreamId, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// set base url (used in relative url support)
|
||||
DIRTYCODE_API void ProtoHttp2SetBaseUrl(ProtoHttp2RefT *pState, const char *pUrl);
|
||||
|
||||
// get location header (requires state and special processing for relative urls)
|
||||
DIRTYCODE_API int32_t ProtoHttp2GetLocationHeader(ProtoHttp2RefT *pState, const char *pInpBuf, char *pBuffer, int32_t iBufSize, const char **pHdrEnd);
|
||||
|
||||
// release resources for the stream identified by id
|
||||
DIRTYCODE_API void ProtoHttp2StreamFree(ProtoHttp2RefT *pState, int32_t iStreamId);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protohttp2_h
|
131
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttpmanager.h
vendored
Normal file
131
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttpmanager.h
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protohttpmanager.h
|
||||
|
||||
\Description
|
||||
High-level module designed to create and manage a pool of ProtoHttp refs. A
|
||||
client application can submit rapid-fire http requests and ProtoHttpManager
|
||||
will distribute them efficiently across the ref pool internally, queuing
|
||||
them for efficient use of keep-alive and pipelining requests where possible.
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Todo
|
||||
Pipelining
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2009.
|
||||
|
||||
\Version 1.0 05/20/2009 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protohttpmanager_h
|
||||
#define _protohttpmanager_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoHttpManager ProtoHttpManager
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protohttp.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! httpmanager stats
|
||||
typedef struct HttpManagerStatT
|
||||
{
|
||||
uint32_t uNumActiveTransactions; //!< current number of active transactions
|
||||
uint32_t uMaxActiveTransactions; //!< maximum (highwater) number of active transactions
|
||||
uint32_t uNumQueuedTransactions; //!< current number of queued transactions
|
||||
uint32_t uMaxQueuedTransactions; //!< maximum (highwater) number of queued transactions
|
||||
uint32_t uNumTransactions; //!< total number of transactions issued
|
||||
uint32_t uNumKeepAliveTransactions; //!< total number of keep-alive transactions issued
|
||||
uint32_t uNumPipelinedTransactions; //!< total number of pipelined transactions issued
|
||||
uint32_t uSumQueueWaitLatency; //!< total amount of time spent waiting in queue
|
||||
uint32_t uMaxQueueWaitLatency; //!< max time any single request had to wait
|
||||
uint32_t uSumQueueFreeLatency; //!< total amount of time spent waiting for transaction to freed
|
||||
uint32_t uMaxQueueFreeLatency; //!< max time any single transaction waited to be freed
|
||||
uint64_t uTransactionBytes; //!< total bytes xferred
|
||||
uint32_t uTransactionTime; //!< total transaction time
|
||||
} HttpManagerStatT;
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct HttpManagerRefT HttpManagerRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate module state and prepare for use
|
||||
DIRTYCODE_API HttpManagerRefT *HttpManagerCreate(int32_t iHttpBufSize, int32_t iHttpNumRefs);
|
||||
|
||||
// set custom header callback
|
||||
DIRTYCODE_API void HttpManagerCallback(HttpManagerRefT *pHttpManager, ProtoHttpCustomHeaderCbT *pCustomHeaderCb, ProtoHttpReceiveHeaderCbT *pReceiveHeaderCb);
|
||||
|
||||
// destroy the module and release its state
|
||||
DIRTYCODE_API void HttpManagerDestroy(HttpManagerRefT *pHttpManager);
|
||||
|
||||
// allocate a new transaction handle
|
||||
DIRTYCODE_API int32_t HttpManagerAlloc(HttpManagerRefT *pHttpManager);
|
||||
|
||||
// release a transaction handle
|
||||
DIRTYCODE_API void HttpManagerFree(HttpManagerRefT *pHttpManager, int32_t iHandle);
|
||||
|
||||
// initiate an HTTP transfer
|
||||
DIRTYCODE_API int32_t HttpManagerGet(HttpManagerRefT *pHttpManager, int32_t iHandle, const char *pUrl, uint32_t bHeadOnly);
|
||||
|
||||
// return the actual url data
|
||||
DIRTYCODE_API int32_t HttpManagerRecv(HttpManagerRefT *pHttpManager, int32_t iHandle, char *pBuffer, int32_t iBufMin, int32_t iBufMax);
|
||||
|
||||
// receive all of the response data
|
||||
DIRTYCODE_API int32_t HttpManagerRecvAll(HttpManagerRefT *pHttpManager, int32_t iHandle, char *pBuffer, int32_t iBufSize);
|
||||
|
||||
// initiate transfer of data to to the server via an HTTP POST command
|
||||
DIRTYCODE_API int32_t HttpManagerPost(HttpManagerRefT *pHttpManager, int32_t iHandle, const char *pUrl, const char *pData, int64_t iDataSize, uint32_t bDoPut);
|
||||
|
||||
// send the actual url data
|
||||
DIRTYCODE_API int32_t HttpManagerSend(HttpManagerRefT *pHttpManager, int32_t iHandle, const char *pData, int32_t iDataSize);
|
||||
|
||||
// make an http request
|
||||
#define HttpManagerRequest(_pHttpManager, _iHandle, _pUrl, _pData, _iDataSize, _eRequestType) HttpManagerRequestCb2(_pHttpManager, _iHandle, _pUrl, _pData, _iDataSize, _eRequestType, NULL, NULL, NULL, NULL)
|
||||
|
||||
// make an http request with write callback
|
||||
#define HttpManagerRequestCb(_pHttpManager, _iHandle, _pUrl, _pData, _iDataSize, _eRequestType, _pWriteCb, _pWriteCbUserData) HttpManagerRequestCb2(_pHttpManager, _iHandle, _pUrl, _pData, _iDataSize, _eRequestType, _pWriteCb, NULL, NULL, _pWriteCbUserData)
|
||||
|
||||
// make an http request with write, custom header and receive header callback
|
||||
DIRTYCODE_API int32_t HttpManagerRequestCb2(HttpManagerRefT *pHttpManager, int32_t iHandle, const char *pUrl, const char *pData, int64_t iDataSize, ProtoHttpRequestTypeE eRequestType, ProtoHttpWriteCbT *pWriteCb, ProtoHttpCustomHeaderCbT *pCustomHeaderCb, ProtoHttpReceiveHeaderCbT *pReceiveHeaderCb, void *pUserData);
|
||||
|
||||
// set base url
|
||||
DIRTYCODE_API void HttpManagerSetBaseUrl(HttpManagerRefT *pHttpManager, int32_t iHandle, const char *pUrl);
|
||||
|
||||
// control function; functionality based on input selector (-1 to apply to all refs)
|
||||
DIRTYCODE_API int32_t HttpManagerControl(HttpManagerRefT *pHttpManager, int32_t iHandle, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// return module status based on input selector
|
||||
DIRTYCODE_API int32_t HttpManagerStatus(HttpManagerRefT *pHttpManager, int32_t iHandle, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
DIRTYCODE_API void HttpManagerUpdate(HttpManagerRefT *pHttpManager);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protohttpmanager_h
|
||||
|
177
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttpserv.h
vendored
Normal file
177
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttpserv.h
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protohttpserv.h
|
||||
|
||||
\Description
|
||||
This module implements an HTTP server that can perform basic transactions
|
||||
(get/put) with an HTTP client. It conforms to but does not fully implement
|
||||
the 1.1 HTTP spec (http://www.w3.org/Protocols/rfc2616/rfc2616.html), and
|
||||
allows for secure HTTP transactions as well as insecure transactions.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2013
|
||||
|
||||
\Version 1.0 12/11/2013 (jbrookes) Initial version, based on HttpServ tester2 module
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protohttpserv_h
|
||||
#define _protohttpserv_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoHttpServ ProtoHttpServ
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protohttputil.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define PROTOHTTPSERV_FLAG_LOOPBACK (0x01) //!< when set, only traffic from the same host will be accepted on the listen port
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct ProtoHttpServRequestT
|
||||
{
|
||||
ProtoHttpRequestTypeE eRequestType; //!< The HTTP method
|
||||
uint32_t uAddr; //!< Address of where the request originated from
|
||||
int64_t iContentLength; //!< `Content-Length` header value, how big is the request
|
||||
int64_t iContentRecv; //!< Amount of data received when processing request
|
||||
char strContentType[64]; //!< `Content-Type` header value, what type of data is being received
|
||||
char strUrl[128]; //!< The path / resource (when a RESTful API) that is being accessed. Example: /person/{id}
|
||||
char strQuery[128]; //!< Query strings passed into the request. Example: ?name="foobar"
|
||||
char strHeader[16*1024]; //!< HTTP headers sent with the request. Use ProtoHttpUtil functions for parsing
|
||||
void *pData; //!< User Specific data (store any data to help handle the request)
|
||||
} ProtoHttpServRequestT;
|
||||
|
||||
typedef struct ProtoHttpServResponseT
|
||||
{
|
||||
ProtoHttpResponseE eResponseCode; //!< The HTTP code (200, 404, etc)
|
||||
char strContentType[64]; //!< `Content-Type` header value, what type of data is being sent
|
||||
int64_t iContentLength; //!< `Content-Length` header value, how much data is being sent.
|
||||
int64_t iContentRead; //!< Amount of data read that is being sent
|
||||
char strHeader[1*1024]; //!< Custom headers being sent
|
||||
int32_t iHeaderLen; //!< Size of the custom headers
|
||||
int32_t iChunkLength; //!< Use `Transfer-Encoding: chunked` if greater than zero
|
||||
char strLocation[1 * 1024]; //!< Redirect Location
|
||||
void *pData; //!< User Specific data (store any data to help respond)
|
||||
} ProtoHttpServResponseT;
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpServRequestCbT
|
||||
|
||||
\Description
|
||||
Invoked when a request is ready for processing
|
||||
|
||||
\Input *pRequest - Information that allows for processing of request
|
||||
\Input *pResponse - [out] Information that ProtoHttpServ used in responding to the request
|
||||
\Input *pUserData - User Specific Data that was passed into ProtoHttpServCallback
|
||||
|
||||
\Output
|
||||
int32_t - zero=complete, positive=in-progress, negative=error
|
||||
*/
|
||||
typedef int32_t (ProtoHttpServRequestCbT)(ProtoHttpServRequestT *pRequest, ProtoHttpServResponseT *pResponse, void *pUserData);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpServReceiveCbT
|
||||
|
||||
\Description
|
||||
Invoked when new incoming data is received for a request
|
||||
|
||||
\Input *pRequest - [in/out] Information about the request
|
||||
\Input *pBuffer - The data that was received (NULL when complete)
|
||||
\Input iBufSize - The size of the data received (zero when complete)
|
||||
\Input *pUserData - User Specific Data that was passed into ProtoHttpServCallback
|
||||
|
||||
\Output
|
||||
int32_t - zero=no data processed, positive=amount of data processed, negative=error
|
||||
*/
|
||||
typedef int32_t (ProtoHttpServReceiveCbT)(ProtoHttpServRequestT *pRequest, const char *pBuffer, int32_t iBufSize, void *pUserData);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpServSendCbT
|
||||
|
||||
\Description
|
||||
Invoked when outgoing data needs to be sent for the response
|
||||
|
||||
\Input *pResponse - Information about the response we are sending
|
||||
\Input *pBuffer - The data we are writting to for the response (NULL when complete)
|
||||
\Input iBufSize - The size of the outgoing buffer (zero when complete)
|
||||
\Input *pUserData - User Specific Data that was passed into ProtoHttpServCallback
|
||||
|
||||
\Output
|
||||
int32_t - positive=amount of data written, other=error
|
||||
*/
|
||||
typedef int32_t (ProtoHttpServSendCbT)(ProtoHttpServResponseT *pResponse, char *pBuffer, int32_t iBufSize, void *pUserData);
|
||||
|
||||
/*!
|
||||
\Callback ProtoHttpServHeaderCbT
|
||||
|
||||
\Description
|
||||
Invoked when a new request header is received
|
||||
|
||||
\Input *pRequest - [in/out] Information about the request we are going to process
|
||||
\Input *pResponse - [out] Used for handling the response, this allows us to error if header is malformed
|
||||
\Input *pUserData - User Specific Data that was passed into ProtoHttpServCallback
|
||||
|
||||
\Output
|
||||
int32_t - positive=success, negative=error
|
||||
*/
|
||||
typedef int32_t (ProtoHttpServHeaderCbT)(ProtoHttpServRequestT *pRequest, ProtoHttpServResponseT *pResponse, void *pUserData);
|
||||
|
||||
//! logging function type
|
||||
typedef void (ProtoHttpServLogCbT)(const char *pText, void *pUserData);
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtoHttpServRefT ProtoHttpServRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create an httpserv module
|
||||
DIRTYCODE_API ProtoHttpServRefT *ProtoHttpServCreate(int32_t iPort, int32_t iSecure, const char *pName);
|
||||
|
||||
// create an httpserv module
|
||||
DIRTYCODE_API ProtoHttpServRefT *ProtoHttpServCreate2(int32_t iPort, int32_t iSecure, const char *pName, uint32_t uFlags);
|
||||
|
||||
// destroy an httpserv module
|
||||
DIRTYCODE_API void ProtoHttpServDestroy(ProtoHttpServRefT *pHttpServ);
|
||||
|
||||
// set httpserv callback function handlers (required)
|
||||
DIRTYCODE_API void ProtoHttpServCallback(ProtoHttpServRefT *pHttpServ, ProtoHttpServRequestCbT *pRequestCb, ProtoHttpServReceiveCbT *pReceiveCb, ProtoHttpServSendCbT *pSendCb, ProtoHttpServHeaderCbT *pHeaderCb, ProtoHttpServLogCbT *pLogCb, void *pUserData);
|
||||
|
||||
// control function; functionality based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttpServControl(ProtoHttpServRefT *pHttpServ, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// control function allowing thread-specific control; functionality based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttpServControl2(ProtoHttpServRefT *pHttpServ, int32_t iThread, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// return module status based on input selector
|
||||
DIRTYCODE_API int32_t ProtoHttpServStatus(ProtoHttpServRefT *pHttpServ, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// update the module
|
||||
DIRTYCODE_API void ProtoHttpServUpdate(ProtoHttpServRefT *pHttpServ);
|
||||
|
||||
// updates the backlog setting on the listen socket, not required to be called unless you need to update the backlog
|
||||
DIRTYCODE_API int32_t ProtoHttpServListen(ProtoHttpServRefT *pHttpServ, int32_t iBacklog);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protohttpserv_h
|
||||
|
||||
|
176
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttputil.h
vendored
Normal file
176
src/thirdparty/dirtysdk/include/DirtySDK/proto/protohttputil.h
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protohttputil.h
|
||||
|
||||
\Description
|
||||
This module implements HTTP support routines such as URL processing, header
|
||||
parsing, etc.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2000-2012.
|
||||
|
||||
\Version 1.0 12/18/2012 (jbrookes) Refactored into separate module from protohttp.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protohttputil_h
|
||||
#define _protohttputil_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoHttpUtil ProtoHttpUtil
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
//! max supported protocol scheme length
|
||||
#define PROTOHTTPUTIL_SCHEME_MAX (32)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
//! get class of response code
|
||||
#define PROTOHTTP_GetResponseClass(_eError) (((_eError)/100) * 100)
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! request types
|
||||
typedef enum ProtoHttpRequestTypeE
|
||||
{
|
||||
PROTOHTTP_REQUESTTYPE_HEAD = 0, //!< HEAD request - does not return any data
|
||||
PROTOHTTP_REQUESTTYPE_GET, //!< GET request - get data from a server
|
||||
PROTOHTTP_REQUESTTYPE_POST, //!< POST request - post data to a server
|
||||
PROTOHTTP_REQUESTTYPE_PUT, //!< PUT request - put data on a server
|
||||
PROTOHTTP_REQUESTTYPE_DELETE, //!< DELETE request - delete resource from a server
|
||||
PROTOHTTP_REQUESTTYPE_OPTIONS, //!< OPTIONS request - get server options for specified resource
|
||||
PROTOHTTP_REQUESTTYPE_PATCH, //!< PATCH request - like PUT but updates the ressource instead of overwriting
|
||||
PROTOHTTP_REQUESTTYPE_CONNECT, //!< CONNECT request - connect to a proxy that can tunnel (internal use only)
|
||||
|
||||
PROTOHTTP_NUMREQUESTTYPES
|
||||
} ProtoHttpRequestTypeE;
|
||||
|
||||
/*! HTTP response codes - see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10
|
||||
for more detailed information. These response codes may be retrieved from ProtoHttp
|
||||
by calling ProtoHttpStatus('code'). Note that response codes are not available until
|
||||
a response has been received from the server and parsed by ProtoHttp. If a response
|
||||
code is not yet available, -1 will be returned. */
|
||||
typedef enum ProtoHttpResponseE
|
||||
{
|
||||
PROTOHTTP_RESPONSE_PENDING = -1, //!< response has not yet been received
|
||||
|
||||
// 1xx - informational reponse
|
||||
PROTOHTTP_RESPONSE_INFORMATIONAL = 100, //!< generic name for a 1xx class response
|
||||
PROTOHTTP_RESPONSE_CONTINUE = 100, //!< continue with request, generally ignored
|
||||
PROTOHTTP_RESPONSE_SWITCHPROTO, //!< 101 - OK response to client switch protocol request
|
||||
|
||||
// 2xx - success response
|
||||
PROTOHTTP_RESPONSE_SUCCESSFUL = 200, //!< generic name for a 2xx class response
|
||||
PROTOHTTP_RESPONSE_OK = 200, //!< client's request was successfully received, understood, and accepted
|
||||
PROTOHTTP_RESPONSE_CREATED, //!< new resource has been created
|
||||
PROTOHTTP_RESPONSE_ACCEPTED, //!< request accepted but not complete
|
||||
PROTOHTTP_RESPONSE_NONAUTH, //!< non-authoritative info (ok)
|
||||
PROTOHTTP_RESPONSE_NOCONTENT, //!< request fulfilled, no message body
|
||||
PROTOHTTP_RESPONSE_RESETCONTENT, //!< request success, reset document view
|
||||
PROTOHTTP_RESPONSE_PARTIALCONTENT, //!< server has fulfilled partial GET request
|
||||
|
||||
// 3xx - redirection response
|
||||
PROTOHTTP_RESPONSE_REDIRECTION = 300, //!< generic name for a 3xx class response
|
||||
PROTOHTTP_RESPONSE_MULTIPLECHOICES = 300, //!< requested resource corresponds to a set of representations
|
||||
PROTOHTTP_RESPONSE_MOVEDPERMANENTLY, //!< requested resource has been moved permanently to new URI
|
||||
PROTOHTTP_RESPONSE_FOUND, //!< requested resources has been moved temporarily to a new URI
|
||||
PROTOHTTP_RESPONSE_SEEOTHER, //!< response can be found under a different URI
|
||||
PROTOHTTP_RESPONSE_NOTMODIFIED, //!< response to conditional get when document has not changed
|
||||
PROTOHTTP_RESPONSE_USEPROXY, //!< requested resource must be accessed through proxy
|
||||
PROTOHTTP_RESPONSE_RESERVED, //!< old response code - reserved
|
||||
PROTOHTTP_RESPONSE_TEMPREDIRECT, //!< requested resource resides temporarily under a different URI
|
||||
|
||||
// 4xx - client error response
|
||||
PROTOHTTP_RESPONSE_CLIENTERROR = 400, //!< generic name for a 4xx class response
|
||||
PROTOHTTP_RESPONSE_BADREQUEST = 400, //!< request could not be understood by server due to malformed syntax
|
||||
PROTOHTTP_RESPONSE_UNAUTHORIZED, //!< request requires user authorization
|
||||
PROTOHTTP_RESPONSE_PAYMENTREQUIRED, //!< reserved for future user
|
||||
PROTOHTTP_RESPONSE_FORBIDDEN, //!< request understood, but server will not fulfill it
|
||||
PROTOHTTP_RESPONSE_NOTFOUND, //!< Request-URI not found
|
||||
PROTOHTTP_RESPONSE_METHODNOTALLOWED, //!< method specified in the Request-Line is not allowed
|
||||
PROTOHTTP_RESPONSE_NOTACCEPTABLE, //!< resource incapable of generating content acceptable according to accept headers in request
|
||||
PROTOHTTP_RESPONSE_PROXYAUTHREQ, //!< client must first authenticate with proxy
|
||||
PROTOHTTP_RESPONSE_REQUESTTIMEOUT, //!< client did not produce response within server timeout
|
||||
PROTOHTTP_RESPONSE_CONFLICT, //!< request could not be completed due to a conflict with current state of the resource
|
||||
PROTOHTTP_RESPONSE_GONE, //!< requested resource is no longer available and no forwarding address is known
|
||||
PROTOHTTP_RESPONSE_LENGTHREQUIRED, //!< a Content-Length header was not specified and is required
|
||||
PROTOHTTP_RESPONSE_PRECONFAILED, //!< precondition given in request-header field(s) failed
|
||||
PROTOHTTP_RESPONSE_REQENTITYTOOLARGE, //!< request entity is larger than the server is able or willing to process
|
||||
PROTOHTTP_RESPONSE_REQURITOOLONG, //!< Request-URI is longer than the server is willing to interpret
|
||||
PROTOHTTP_RESPONSE_UNSUPPORTEDMEDIA, //!< request entity is in unsupported format
|
||||
PROTOHTTP_RESPONSE_REQUESTRANGE, //!< invalid range in Range request header
|
||||
PROTOHTTP_RESPONSE_EXPECTATIONFAILED, //!< expectation in Expect request-header field could not be met by server
|
||||
|
||||
// 5xx - server error response
|
||||
PROTOHTTP_RESPONSE_SERVERERROR = 500, //!< generic name for a 5xx class response
|
||||
PROTOHTTP_RESPONSE_INTERNALSERVERERROR = 500, //!< an unexpected condition prevented the server from fulfilling the request
|
||||
PROTOHTTP_RESPONSE_NOTIMPLEMENTED, //!< the server does not support the functionality required to fulfill the request
|
||||
PROTOHTTP_RESPONSE_BADGATEWAY, //!< invalid response from gateway server
|
||||
PROTOHTTP_RESPONSE_SERVICEUNAVAILABLE, //!< unable to handle request due to a temporary overloading or maintainance
|
||||
PROTOHTTP_RESPONSE_GATEWAYTIMEOUT, //!< gateway or DNS server timeout
|
||||
PROTOHTTP_RESPONSE_HTTPVERSUNSUPPORTED //!< the server does not support the HTTP protocol version that was used in the request
|
||||
} ProtoHttpResponseE;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// parse HTTP request line from the format as sent on the wire
|
||||
DIRTYCODE_API const char *ProtoHttpUtilParseRequest(const char *pStrHeader, char *pStrMethod, int32_t iMethodLen, char *pStrUri, int32_t iUriLen, char *pStrQuery, int32_t iQueryLen, ProtoHttpRequestTypeE *pRequestType, uint8_t *pHttp1_0);
|
||||
|
||||
// finds the header field value for the specified header field
|
||||
DIRTYCODE_API const char *ProtoHttpFindHeaderValue(const char *pHdrBuf, const char *pHeaderText);
|
||||
|
||||
// extracts the header field value for the specified header field entry
|
||||
DIRTYCODE_API int32_t ProtoHttpExtractHeaderValue(const char *pHdrField, char *pOutBuf, int32_t iOutLen, const char **ppHdrEnd);
|
||||
|
||||
// parse header response code from HTTP header
|
||||
DIRTYCODE_API int32_t ProtoHttpParseHeaderCode(const char *pHdrBuf);
|
||||
|
||||
// extract a header value from the specified header text
|
||||
DIRTYCODE_API int32_t ProtoHttpGetHeaderValue(void *pState, const char *pHdrBuf, const char *pName, char *pBuffer, int32_t iBufSize, const char **pHdrEnd);
|
||||
|
||||
// get next header name and value from header buffer
|
||||
DIRTYCODE_API int32_t ProtoHttpGetNextHeader(void *pState, const char *pHdrBuf, char *pName, int32_t iNameSize, char *pValue, int32_t iValSize, const char **pHdrEnd);
|
||||
|
||||
// url-encode a integer parameter
|
||||
DIRTYCODE_API int32_t ProtoHttpUrlEncodeIntParm(char *pBuffer, int32_t iLength, const char *pParm, int32_t iValue);
|
||||
|
||||
// url-encode a string parameter
|
||||
DIRTYCODE_API int32_t ProtoHttpUrlEncodeStrParm(char *pBuffer, int32_t iLength, const char *pParm, const char *pData);
|
||||
|
||||
// url-encode a string parameter with custom safe table
|
||||
DIRTYCODE_API int32_t ProtoHttpUrlEncodeStrParm2(char *pBuffer, int32_t iLength, const char *pParm, const char *pData, const char *pStrSafe);
|
||||
|
||||
// url-decode a string parameter
|
||||
DIRTYCODE_API int32_t ProtoHttpUrlDecodeStrParm(const char *pBuffer, char *pData, int32_t iDataSize);
|
||||
|
||||
// parse a url into component parts
|
||||
DIRTYCODE_API const char *ProtoHttpUrlParse(const char *pUrl, char *pKind, int32_t iKindSize, char *pHost, int32_t iHostSize, int32_t *pPort, int32_t *pSecure);
|
||||
|
||||
// parse a url into component parts
|
||||
DIRTYCODE_API const char *ProtoHttpUrlParse2(const char *pUrl, char *pKind, int32_t iKindSize, char *pHost, int32_t iHostSize, int32_t *pPort, int32_t *pSecure, uint8_t *bPortSpecified);
|
||||
|
||||
// get next param name and value from URI buffer
|
||||
DIRTYCODE_API int32_t ProtoHttpGetNextParam(void *pState, const char *pUriBuf, char *pName, int32_t iNameSize, char *pValue, int32_t iValSize, const char **pUriEnd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protohttp_h
|
||||
|
139
src/thirdparty/dirtysdk/include/DirtySDK/proto/protomangle.h
vendored
Normal file
139
src/thirdparty/dirtysdk/include/DirtySDK/proto/protomangle.h
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File protomangle.h
|
||||
|
||||
\Description
|
||||
This module encapsulates use of the EA.Com Demangler service.
|
||||
|
||||
\Notes
|
||||
The ProtoMangle client was developed from version 1.1 of the Peer Connection Service
|
||||
Protocol Specification:
|
||||
|
||||
http://docs.online.ea.com/infrastructure/demangler/peer-connection-service-protocol.doc
|
||||
|
||||
Please see the following documentation for information on the Demangler service:
|
||||
|
||||
http://docs.online.ea.com/infrastructure/demangler/demangler.html
|
||||
http://docs.online.ea.com/infrastructure/demangler/peer-connection-service-reqs.doc
|
||||
http://docs.online.ea.com/infrastructure/demangler/peer-connection-service-engineering-spec.doc
|
||||
http://docs.online.ea.com/infrastructure/demangler/Peer-Connection-Service-Architecture.doc
|
||||
|
||||
Original work done by C&C: Red Alert 2, on which the Demangler service is based:
|
||||
|
||||
http://www.worldwide.ea.com/articles/render/attachment.aspx?id=919
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2003. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 04/03/2003 (JLB) First Version
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _protomangle_h
|
||||
#define _protomangle_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoMangle ProtoMangle
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! max cookie length, including terminator
|
||||
#define PROTOMANGLE_STRCOOKIE_MAX (64)
|
||||
|
||||
//! max gameFeatureID length, including terminator
|
||||
#define PROTOMANGLE_STRGAMEID_MAX (32)
|
||||
|
||||
//! max LKey length, including terminator
|
||||
#define PROTOMANGLE_STRLKEY_MAX (64)
|
||||
|
||||
//! max server name length, including terminator
|
||||
#define PROTOMANGLE_STRSERVER_MAX (32)
|
||||
|
||||
/*
|
||||
Default server name/port
|
||||
*/
|
||||
|
||||
//! default server name
|
||||
#define PROTOMANGLE_SERVER ("demangler.ea.com")
|
||||
|
||||
//! development server
|
||||
#define PROTOMANGLE_TEST_SERVER ("peach.online.ea.com")
|
||||
|
||||
//! default server port
|
||||
#define PROTOMANGLE_PORT (3658)
|
||||
|
||||
//! response codes
|
||||
typedef enum ProtoMangleStatusE
|
||||
{
|
||||
PROTOMANGLE_STATUS_CONNECTED,
|
||||
PROTOMANGLE_STATUS_FAILED,
|
||||
|
||||
PROTOMANGLE_NUMSTATUS
|
||||
} ProtoMangleStatusE;
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
typedef struct ProtoMangleRefT ProtoMangleRefT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate module state and prepare for use
|
||||
DIRTYCODE_API ProtoMangleRefT *ProtoMangleCreate(const char *pServer, int32_t iPort, const char *pGameID, const char *pLKey);
|
||||
|
||||
// destroy the module and release its state
|
||||
DIRTYCODE_API void ProtoMangleDestroy(ProtoMangleRefT *pRef);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
DIRTYCODE_API void ProtoMangleUpdate(ProtoMangleRefT *pRef);
|
||||
|
||||
// connect to demangler server
|
||||
DIRTYCODE_API void ProtoMangleConnect(ProtoMangleRefT *pRef, int32_t iGamePort, const char *pSessID);
|
||||
|
||||
// connect to demangler server (extended)
|
||||
DIRTYCODE_API void ProtoMangleConnect2(ProtoMangleRefT *pRef, int32_t iGamePort, const char *pSessID, int32_t iSessIDLen);
|
||||
|
||||
// connect to demangler server, using the given socket ref to issue UDP probes instead of creating one
|
||||
DIRTYCODE_API void ProtoMangleConnectSocket(ProtoMangleRefT *pRef, intptr_t uSocketRef, const char *pSessID);
|
||||
|
||||
// get result
|
||||
DIRTYCODE_API int32_t ProtoMangleComplete(ProtoMangleRefT *pRef, int32_t *pAddr, int32_t *pPort);
|
||||
|
||||
// submit result to server
|
||||
DIRTYCODE_API int32_t ProtoMangleReport(ProtoMangleRefT *pRef, ProtoMangleStatusE eStatus, int32_t iLatency);
|
||||
|
||||
// protomangle control
|
||||
DIRTYCODE_API int32_t ProtoMangleControl(ProtoMangleRefT *pRef, int32_t iControl, int32_t iValue, int32_t iValue2, const void *pValue);
|
||||
|
||||
// get module status based on selector
|
||||
DIRTYCODE_API int32_t ProtoMangleStatus(ProtoMangleRefT *pRef, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// find a secure template for given network parameters
|
||||
#if defined(DIRTYCODE_XBOXONE) && !defined(DIRTYCODE_GDK)
|
||||
const char *ProtoMangleFindTemplate(char *pStrTemplateName, int32_t iTemplateNameSize, int32_t iLocalPort, int32_t iRemotePort, uint8_t bTcp, int32_t iVerbose);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protomangle_h
|
||||
|
||||
|
63
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoname.h
vendored
Normal file
63
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoname.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File protoname.h
|
||||
|
||||
\Description
|
||||
This module provides name lookup services via DNS. It is platform indepedent
|
||||
and can be used to resolve names for use with other protocol modules. At this
|
||||
point, name support is being removed from other protocol modules so it can be
|
||||
centralized here.
|
||||
|
||||
\Notes
|
||||
None.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2002. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 03/19/02 (GWS) First Version
|
||||
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _protoname_h
|
||||
#define _protoname_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoName ProtoName
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/dirtysock/dirtynet.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// async lookup of a domain name
|
||||
DIRTYCODE_API HostentT *ProtoNameAsync(const char *pName, int32_t iTimeout);
|
||||
|
||||
// synchronous (blocking) lookup of a domain name.
|
||||
DIRTYCODE_API uint32_t ProtoNameSync(const char *pName, int32_t iTimeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protoname_h
|
277
src/thirdparty/dirtysdk/include/DirtySDK/proto/protossl.h
vendored
Normal file
277
src/thirdparty/dirtysdk/include/DirtySDK/proto/protossl.h
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
\File protossl.h
|
||||
|
||||
\Description
|
||||
This module is a from-scratch TLS implementation. It does not use any
|
||||
third-party code of any kind and was developed entirely by EA.
|
||||
|
||||
\Notes
|
||||
References:
|
||||
TLS1.0 RFC: https://tools.ietf.org/html/rfc2246
|
||||
TLS1.1 RFC: https://tools.ietf.org/html/rfc4346
|
||||
TLS1.2 RFC: https://tools.ietf.org/html/rfc5246
|
||||
TLS1.3 RFC: https://tools.ietf.org/html/rfc8446
|
||||
ASN.1 encoding rules: https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2002-2018
|
||||
|
||||
\Version 03/08/2002 (gschaefer) Initial SSL 2.0 implementation
|
||||
\Version 03/03/2004 (sbevan) Added certificate validation
|
||||
\Version 11/05/2005 (gschaefer) Rewritten to follow SSL 3.0 specification
|
||||
\Version 10/12/2012 (jbrookes) Added support for TLS1.0 & TLS1.1
|
||||
\Version 10/20/2013 (jbrookes) Added server handshake, client cert support
|
||||
\Version 11/06/2013 (jbrookes) Added support for TLS1.2
|
||||
\Version 03/31/2017 (eesponda) Added support for EC ciphers
|
||||
\Version 03/28/2018 (jbrookes) Added support for TLS1.3
|
||||
\Version 08/15/2018 (jbrookes) Removed SSLv3 & RC4 ciphers
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _protossl_h
|
||||
#define _protossl_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoSSL ProtoSSL
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/crypt/cryptdef.h"
|
||||
#include "DirtySDK/crypt/cryptrsa.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
// supported TLS versions
|
||||
#define PROTOSSL_VERSION_TLS1_0 (0x0301)
|
||||
#define PROTOSSL_VERSION_TLS1_1 (0x0302)
|
||||
#define PROTOSSL_VERSION_TLS1_2 (0x0303)
|
||||
#define PROTOSSL_VERSION_TLS1_3 (0x0304)
|
||||
|
||||
// protossl failure codes (retrieve with ProtoSSLStat('fail')
|
||||
#define PROTOSSL_ERROR_NONE ( 0) //!< no error
|
||||
#define PROTOSSL_ERROR_DNS (-1) //!< DNS failure
|
||||
#define PROTOSSL_ERROR_CONN (-10) //!< TCP connection failure
|
||||
#define PROTOSSL_ERROR_CONN_SSL2 (-11) //!< connection attempt was using unsupported SSLv2 record format
|
||||
#define PROTOSSL_ERROR_CONN_NOTSSL (-12) //!< connection attempt was not recognized as SSL
|
||||
#define PROTOSSL_ERROR_CONN_MINVERS (-13) //!< request failed minimum protocol version restriction
|
||||
#define PROTOSSL_ERROR_CONN_MAXVERS (-14) //!< request failed maximum protocol version restriction
|
||||
#define PROTOSSL_ERROR_CONN_NOCIPHER (-15) //!< no supported cipher
|
||||
#define PROTOSSL_ERROR_CONN_NOCURVE (-16) //!< no supported curve
|
||||
#define PROTOSSL_ERROR_CERT_INVALID (-20) //!< certificate invalid
|
||||
#define PROTOSSL_ERROR_CERT_HOST (-21) //!< certificate not issued to this host
|
||||
#define PROTOSSL_ERROR_CERT_NOTRUST (-22) //!< certificate is not trusted (recognized)
|
||||
#define PROTOSSL_ERROR_CERT_MISSING (-23) //!< certificate not provided in certificate message
|
||||
#define PROTOSSL_ERROR_CERT_BADDATE (-24) //!< certificate date range validity check failed
|
||||
#define PROTOSSL_ERROR_CERT_REQUEST (-25) //!< CA fetch request failed
|
||||
#define PROTOSSL_ERROR_SETUP (-30) //!< failure in secure setup
|
||||
#define PROTOSSL_ERROR_SECURE (-31) //!< failure in secure connection after setup
|
||||
#define PROTOSSL_ERROR_UNKNOWN (-32) //!< unknown failure
|
||||
|
||||
// SSLv3 cipher suites (available for TLS1.0+ although SSLv3 is no longer supported)
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_128_CBC_SHA (1<<0)
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_256_CBC_SHA (1<<1)
|
||||
// TLS1.0 cipher suites
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_CBC_SHA (1<<2)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_CBC_SHA (1<<3)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_CBC_SHA (1<<4)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (1<<5)
|
||||
// TLS1.2 cipher suites
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_128_CBC_SHA256 (1<<6)
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_256_CBC_SHA256 (1<<7)
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_128_GCM_SHA256 (1<<8)
|
||||
#define PROTOSSL_CIPHER_RSA_WITH_AES_256_GCM_SHA384 (1<<9)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (1<<10)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (1<<11)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (1<<12)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (1<<13)
|
||||
#define PROTOSSL_CIPHER_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (1<<14)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 (1<<15)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 (1<<16)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (1<<17)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (1<<18)
|
||||
#define PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (1<<19)
|
||||
// TLS1.3 cipher suites
|
||||
#define PROTOSSL_CIPHER_AES_128_GCM_SHA256 (1<<20)
|
||||
#define PROTOSSL_CIPHER_AES_256_GCM_SHA384 (1<<21)
|
||||
#define PROTOSSL_CIPHER_CHACHA20_POLY1305_SHA256 (1<<22)
|
||||
|
||||
//! all rsa cipher suites (minus disabled rc4-md5)
|
||||
#define PROTOSSL_CIPHER_RSA (\
|
||||
PROTOSSL_CIPHER_RSA_WITH_AES_128_CBC_SHA|PROTOSSL_CIPHER_RSA_WITH_AES_256_CBC_SHA|\
|
||||
PROTOSSL_CIPHER_RSA_WITH_AES_128_CBC_SHA256|PROTOSSL_CIPHER_RSA_WITH_AES_128_GCM_SHA256|\
|
||||
PROTOSSL_CIPHER_RSA_WITH_AES_256_CBC_SHA256|PROTOSSL_CIPHER_RSA_WITH_AES_256_GCM_SHA384)
|
||||
|
||||
//! all ecc cipher suites
|
||||
#define PROTOSSL_CIPHER_ECC (\
|
||||
PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_CBC_SHA|PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_CBC_SHA256|\
|
||||
PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_CBC_SHA|PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_CBC_SHA384|\
|
||||
PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_128_GCM_SHA256|PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_CBC_SHA|\
|
||||
PROTOSSL_CIPHER_ECDHE_RSA_WITH_AES_256_GCM_SHA384|PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_CBC_SHA|\
|
||||
PROTOSSL_CIPHER_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|\
|
||||
PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256|PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256|\
|
||||
PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384|PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384|\
|
||||
PROTOSSL_CIPHER_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256)
|
||||
|
||||
//! all tls1.3 cipher suites
|
||||
#define PROTOSSL_CIPHER_ALL_13 (PROTOSSL_CIPHER_AES_128_GCM_SHA256|PROTOSSL_CIPHER_AES_256_GCM_SHA384|PROTOSSL_CIPHER_CHACHA20_POLY1305_SHA256)
|
||||
|
||||
//! default cipher suites
|
||||
#define PROTOSSL_CIPHER_ALL (PROTOSSL_CIPHER_RSA|PROTOSSL_CIPHER_ECC|PROTOSSL_CIPHER_ALL_13)
|
||||
|
||||
// client cert flags (ProtoSSLControl() 'ccrt' selector)
|
||||
#define PROTOSSL_CLIENTCERT_NONE (0)
|
||||
#define PROTOSSL_CLIENTCERT_OPTIONAL (1)
|
||||
#define PROTOSSL_CLIENTCERT_REQUIRED (2)
|
||||
|
||||
// clienthello extensions
|
||||
#define PROTOSSL_HELLOEXTN_NONE (0)
|
||||
#define PROTOSSL_HELLOEXTN_SERVERNAME (1)
|
||||
#define PROTOSSL_HELLOEXTN_SIGALGS (2)
|
||||
#define PROTOSSL_HELLOEXTN_ALPN (4)
|
||||
#define PROTOSSL_HELLOEXTN_ELLIPTIC_CURVES (8)
|
||||
// all extensions
|
||||
#define PROTOSSL_HELLOEXTN_ALL (\
|
||||
PROTOSSL_HELLOEXTN_SERVERNAME|PROTOSSL_HELLOEXTN_SIGALGS|PROTOSSL_HELLOEXTN_ALPN)
|
||||
// default extensions
|
||||
#define PROTOSSL_HELLOEXTN_DEFAULT (PROTOSSL_HELLOEXTN_ALL)
|
||||
|
||||
//! elliptic curves
|
||||
#define PROTOSSL_CURVE_SECP256R1 (1 << 0)
|
||||
#define PROTOSSL_CURVE_SECP384R1 (1 << 1)
|
||||
#define PROTOSSL_CURVE_X25519 (1 << 2)
|
||||
#define PROTOSSL_CURVE_X448 (1 << 3)
|
||||
|
||||
//! all curves
|
||||
#define PROTOSSL_CURVE_ALL (\
|
||||
PROTOSSL_CURVE_SECP256R1|PROTOSSL_CURVE_SECP384R1|PROTOSSL_CURVE_X25519|PROTOSSL_CURVE_X448)
|
||||
//! default curves
|
||||
#define PROTOSSL_CURVE_DEFAULT (PROTOSSL_CURVE_ALL)
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! identity fields for X509 issuer/subject
|
||||
typedef struct ProtoSSLCertIdentT
|
||||
{
|
||||
char strCountry[32];
|
||||
char strState[32];
|
||||
char strCity[32];
|
||||
char strOrg[32];
|
||||
char strUnit[256];
|
||||
char strCommon[64];
|
||||
} ProtoSSLCertIdentT;
|
||||
|
||||
//! alert info, returned by ProtoSSLStat() 'alrt' selector after an SSL alert has been received
|
||||
typedef struct ProtoSSLAlertDescT
|
||||
{
|
||||
int32_t iAlertType;
|
||||
const char *pAlertDesc;
|
||||
} ProtoSSLAlertDescT;
|
||||
|
||||
//! cert info, returned by ProtoSSLStat() 'cert' selector after certificate failure
|
||||
typedef struct ProtoSSLCertInfoT
|
||||
{
|
||||
ProtoSSLCertIdentT Ident;
|
||||
int32_t iKeyModSize;
|
||||
} ProtoSSLCertInfoT;
|
||||
|
||||
//! state for pkcs1 operations
|
||||
typedef struct ProtoSSLPkcs1T
|
||||
{
|
||||
CryptRSAT RSAContext; //!< context used for rsa operations
|
||||
} ProtoSSLPkcs1T;
|
||||
|
||||
// opaque module state ref
|
||||
typedef struct ProtoSSLRefT ProtoSSLRefT;
|
||||
|
||||
// forward declaration of sockaddr
|
||||
struct sockaddr;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// protossl startup
|
||||
DIRTYCODE_API int32_t ProtoSSLStartup(void);
|
||||
|
||||
// protossl shutdown
|
||||
DIRTYCODE_API void ProtoSSLShutdown(void);
|
||||
|
||||
// allocate an SSL connection and prepare for use
|
||||
DIRTYCODE_API ProtoSSLRefT *ProtoSSLCreate(void);
|
||||
|
||||
// reset connection back to base state.
|
||||
DIRTYCODE_API void ProtoSSLReset(ProtoSSLRefT *pState);
|
||||
|
||||
// destroy the module and release its state
|
||||
DIRTYCODE_API void ProtoSSLDestroy(ProtoSSLRefT *pState);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
DIRTYCODE_API void ProtoSSLUpdate(ProtoSSLRefT *pState);
|
||||
|
||||
// Accept an incoming connection.
|
||||
DIRTYCODE_API ProtoSSLRefT* ProtoSSLAccept(ProtoSSLRefT *pState, int32_t iSecure, struct sockaddr *pAddr, int32_t *pAddrlen);
|
||||
|
||||
// Create a socket bound to the given address.
|
||||
DIRTYCODE_API int32_t ProtoSSLBind(ProtoSSLRefT *pState, const struct sockaddr *pAddr, int32_t pAddrlen);
|
||||
|
||||
// make a secure connection to a server.
|
||||
DIRTYCODE_API int32_t ProtoSSLConnect(ProtoSSLRefT *pState, int32_t iSecure, const char *pAddr, uint32_t uAddr, int32_t iPort);
|
||||
|
||||
// disconnect from the server.
|
||||
DIRTYCODE_API int32_t ProtoSSLDisconnect(ProtoSSLRefT *pState);
|
||||
|
||||
// Start listening for an incoming connection.
|
||||
DIRTYCODE_API int32_t ProtoSSLListen(ProtoSSLRefT *pState, int32_t iBacklog);
|
||||
|
||||
// send secure data to the server.
|
||||
DIRTYCODE_API int32_t ProtoSSLSend(ProtoSSLRefT *pState, const char *pBuffer, int32_t iLength);
|
||||
|
||||
// receive secure data from the server.
|
||||
DIRTYCODE_API int32_t ProtoSSLRecv(ProtoSSLRefT *pState, char *pBuffer, int32_t iLength);
|
||||
|
||||
// return the current module status (according to selector)
|
||||
DIRTYCODE_API int32_t ProtoSSLStat(ProtoSSLRefT *pState, int32_t iSelect, void *pBuffer, int32_t iLength);
|
||||
|
||||
// control module behavior
|
||||
DIRTYCODE_API int32_t ProtoSSLControl(ProtoSSLRefT *pState, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// add an X.509 CA certificate that will be recognized in future transactions
|
||||
DIRTYCODE_API int32_t ProtoSSLSetCACert(const uint8_t *pCACert, int32_t iCertSize);
|
||||
|
||||
// same as ProtoSSLSetCACert(), but certs are not validated at load time
|
||||
DIRTYCODE_API int32_t ProtoSSLSetCACert2(const uint8_t *pCACert, int32_t iCertSize);
|
||||
|
||||
// validate all CAs that have not already been validated
|
||||
DIRTYCODE_API int32_t ProtoSSLValidateAllCA(void);
|
||||
|
||||
// clear all CA certs
|
||||
DIRTYCODE_API void ProtoSSLClrCACerts(void);
|
||||
|
||||
// generate a pkcs1.5 rsa signature - init
|
||||
DIRTYCODE_API int32_t ProtoSSLPkcs1GenerateInit(ProtoSSLPkcs1T *pPkcs1, const uint8_t *pHashData, int32_t iHashLen, int32_t iHashType, int32_t iModSize, const CryptBinaryObjT *pPrimeP, const CryptBinaryObjT *pPrimeQ, const CryptBinaryObjT *pExponentP, const CryptBinaryObjT *pExponentQ, const CryptBinaryObjT *pCoefficient);
|
||||
|
||||
// generate a pkcs1.5 rsa signature
|
||||
DIRTYCODE_API int32_t ProtoSSLPkcs1GenerateUpdate(ProtoSSLPkcs1T *pPkcs1, int32_t iNumIterations, uint8_t *pSigData, int32_t iSigSize);
|
||||
|
||||
// verify the pkcs1.5 rsa signature
|
||||
DIRTYCODE_API int32_t ProtoSSLPkcs1Verify(const uint8_t *pSignature, int32_t iSigLen, const uint8_t *pHashData, int32_t iHashLen, int32_t iHashType, const uint8_t *pMod, int32_t iModSize, const uint8_t *pExp, int32_t iExpSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protossl_h
|
||||
|
107
src/thirdparty/dirtysdk/include/DirtySDK/proto/protostream.h
vendored
Normal file
107
src/thirdparty/dirtysdk/include/DirtySDK/proto/protostream.h
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protostream.h
|
||||
|
||||
\Description
|
||||
Manage streaming of an Internet media resource.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 11/16/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protostream_h
|
||||
#define _protostream_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoStream ProtoStream
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/proto/protohttp.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/* when a stream is opened, the repeat frequency is specified in seconds. these
|
||||
constants handle special cases of "one time play" (once) and "immediate
|
||||
restart" (immed). */
|
||||
#define PROTOSTREAM_FREQ_ONCE (-1) //!< one time play
|
||||
#define PROTOSTREAM_FREQ_IMMED (0) //!< immediate restart
|
||||
|
||||
//! callback status indicating state of the stream
|
||||
typedef enum ProtoStreamStatusE
|
||||
{
|
||||
PROTOSTREAM_STATUS_BEGIN = 0, //!< first buffer of data (start of stream)
|
||||
PROTOSTREAM_STATUS_DATA, //!< data has been received
|
||||
PROTOSTREAM_STATUS_SYNC, //!< data was dropped from the stream
|
||||
PROTOSTREAM_STATUS_DONE //!< end of stream (no data)
|
||||
} ProtoStreamStatusE;
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module state
|
||||
typedef struct ProtoStreamRefT ProtoStreamRefT;
|
||||
|
||||
//! data callback definition
|
||||
typedef int32_t (ProtoStreamCallbackT)(ProtoStreamRefT *pProtoStream, ProtoStreamStatusE eStatus, const uint8_t *pBuffer, int32_t iBufSize, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module
|
||||
DIRTYCODE_API ProtoStreamRefT *ProtoStreamCreate(int32_t iBufSize);
|
||||
|
||||
// destroy the module
|
||||
DIRTYCODE_API void ProtoStreamDestroy(ProtoStreamRefT *pProtoStream);
|
||||
|
||||
// set recurring callback
|
||||
DIRTYCODE_API void ProtoStreamSetCallback(ProtoStreamRefT *pProtoStream, int32_t iRate, ProtoStreamCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// set http custom header send/recv callbacks
|
||||
DIRTYCODE_API void ProtoStreamSetHttpCallback(ProtoStreamRefT *pProtoStream, ProtoHttpCustomHeaderCbT *pCustomHeaderCb, ProtoHttpReceiveHeaderCbT *pReceiveHeaderCb, void *pUserData);
|
||||
|
||||
// begin streaming an internet media resource
|
||||
DIRTYCODE_API int32_t ProtoStreamOpen(ProtoStreamRefT *pProtoStream, const char *pUrl, int32_t iFreq);
|
||||
|
||||
// begin streaming an internet media resource, with a request body (using POST)
|
||||
DIRTYCODE_API int32_t ProtoStreamOpen2(ProtoStreamRefT *pProtoStream, const char *pUrl, const char *pReq, int32_t iFreq);
|
||||
|
||||
// read at least iMinLen bytes from stream into user buffer
|
||||
DIRTYCODE_API int32_t ProtoStreamRead(ProtoStreamRefT *pProtoStream, char *pBuffer, int32_t iBufLen, int32_t iMinLen);
|
||||
|
||||
// pause stream
|
||||
DIRTYCODE_API void ProtoStreamPause(ProtoStreamRefT *pProtoStream, uint8_t bPause);
|
||||
|
||||
// stop streaming
|
||||
DIRTYCODE_API void ProtoStreamClose(ProtoStreamRefT *pProtoStream);
|
||||
|
||||
// get module status
|
||||
DIRTYCODE_API int32_t ProtoStreamStatus(ProtoStreamRefT *pProtoStream, int32_t iStatus, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// set control options
|
||||
DIRTYCODE_API int32_t ProtoStreamControl(ProtoStreamRefT *pProtoStream, int32_t iControl, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// update module
|
||||
DIRTYCODE_API void ProtoStreamUpdate(ProtoStreamRefT *pProtoStream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protostream_h
|
||||
|
148
src/thirdparty/dirtysdk/include/DirtySDK/proto/prototunnel.h
vendored
Normal file
148
src/thirdparty/dirtysdk/include/DirtySDK/proto/prototunnel.h
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File prototunnel.h
|
||||
|
||||
\Description
|
||||
ProtoTunnel creates and manages a Virtual DirtySock Tunnel (VDST)
|
||||
connection. The tunnel transparently bundles data sent from multiple ports
|
||||
to a specific remote host into a single send, and optionally encrypts
|
||||
portions of that packet. Only data sent over a UDP socket may be
|
||||
tunneled.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 12/02/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _prototunnel_h
|
||||
#define _prototunnel_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoTunnel ProtoTunnel
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// prototunnel protocol versions (maj.min)
|
||||
#define PROTOTUNNEL_VERSION_1_1 (0x0101)
|
||||
#define PROTOTUNNEL_VERSION (PROTOTUNNEL_VERSION_1_1) //!< default protocol version
|
||||
#define PROTOTUNNEL_VERSION_MIN (PROTOTUNNEL_VERSION_1_1) //!< minimum protocol version
|
||||
#define PROTOTUNNEL_VERSION_MAX (PROTOTUNNEL_VERSION_1_1) //!< maximum protocol version
|
||||
|
||||
//! maximum number of ports that can be mapped to a tunnel
|
||||
#define PROTOTUNNEL_MAXPORTS (8)
|
||||
|
||||
//! port flag indicating data is encrypted
|
||||
#define PROTOTUNNEL_PORTFLAG_ENCRYPTED (1)
|
||||
#define PROTOTUNNEL_PORTFLAG_AUTOFLUSH (2)
|
||||
|
||||
//! max key length
|
||||
#define PROTOTUNNEL_MAXKEYLEN (128)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! tunnel event types
|
||||
typedef enum ProtoTunnelEventE
|
||||
{
|
||||
PROTOTUNNEL_EVENT_RECVNOMATCH, //!< data received from source with no tunnel mapping
|
||||
|
||||
PROTOTUNNEL_NUMEVENTS //!< total number of events
|
||||
} ProtoTunnelEventE;
|
||||
|
||||
//! map description
|
||||
typedef struct ProtoTunnelInfoT
|
||||
{
|
||||
uint32_t uRemoteClientId; //!< unique client ID of remote client
|
||||
uint32_t uRemoteAddr; //!< remote tunnel address
|
||||
uint16_t uRemotePort; //!< remote tunnel port (if zero, use local port)
|
||||
uint16_t aRemotePortList[PROTOTUNNEL_MAXPORTS]; //!< port(s) to map
|
||||
uint8_t aPortFlags[PROTOTUNNEL_MAXPORTS]; //!< port flags
|
||||
uint16_t uTunnelVers; //!< tunnel protocol version
|
||||
uint8_t _pad[2];
|
||||
} ProtoTunnelInfoT;
|
||||
|
||||
//! tunnel statistics
|
||||
typedef struct ProtoTunnelStatT
|
||||
{
|
||||
uint32_t uLastPacketTime; //!< last time packet was snet or received
|
||||
uint32_t uUpdateTime; //!< time when ProtoTunnelStatT was updated
|
||||
uint32_t uPrevUpdateTime; //!< last time ProtoTunnelStatT was updated (can be used to keep track of update interval)
|
||||
uint32_t uEfficiency; //!< send/receive efficiency for the last update interval
|
||||
uint32_t uRawBytesPerSecond; //!< raw byte per second for the last update interval
|
||||
uint32_t uBytePerSecond; //!< data bytes (user data) per second for the last update interval
|
||||
uint32_t uNumBytes; //!< total number of bytes
|
||||
uint32_t uNumSubpacketBytes; //!< total number of subpacket bytes (user data)
|
||||
uint16_t uNumPackets; //!< total number of packets
|
||||
uint16_t uNumSubpackets; //!< total number of subpackets
|
||||
uint16_t uNumDiscards; //!< total number of out-of-order packet discards
|
||||
uint16_t _pad;
|
||||
} ProtoTunnelStatT;
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtoTunnelRefT ProtoTunnelRefT;
|
||||
|
||||
//! prototunnel event callback
|
||||
typedef void (ProtoTunnelCallbackT)(ProtoTunnelRefT *pProtoTunnel, ProtoTunnelEventE eEvent, const char *pData, int32_t iDataSize, struct sockaddr *pRecvAddr, void *pUserData);
|
||||
|
||||
//! raw inbound data receive callback (shall return 1 if it swallows the data, 0 otherwise)
|
||||
typedef int32_t (RawRecvCallbackT)(SocketT *pSocket, uint8_t *pData, int32_t iRecvLen, const struct sockaddr *pFrom, int32_t iFromLen, void *pUserData);
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module
|
||||
DIRTYCODE_API ProtoTunnelRefT *ProtoTunnelCreate(int32_t iMaxTunnels, int32_t iTunnelPort);
|
||||
|
||||
// destroy the module
|
||||
DIRTYCODE_API void ProtoTunnelDestroy(ProtoTunnelRefT *pProtoTunnel);
|
||||
|
||||
// set event callback
|
||||
DIRTYCODE_API void ProtoTunnelCallback(ProtoTunnelRefT *pProtoTunnel, ProtoTunnelCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// allocate a tunnel
|
||||
DIRTYCODE_API int32_t ProtoTunnelAlloc(ProtoTunnelRefT *pProtoTunnel, ProtoTunnelInfoT *pInfo, const char *pKey);
|
||||
|
||||
// free a tunnel
|
||||
DIRTYCODE_API uint32_t ProtoTunnelFree(ProtoTunnelRefT *pProtoTunnel, uint32_t uTunnelId, const char *pKey);
|
||||
|
||||
// free a tunnel
|
||||
DIRTYCODE_API uint32_t ProtoTunnelFree2(ProtoTunnelRefT *pProtoTunnel, uint32_t uTunnelId, const char *pKey, uint32_t uAddr);
|
||||
|
||||
// update port mapping for specified tunnel
|
||||
DIRTYCODE_API int32_t ProtoTunnelUpdatePortList(ProtoTunnelRefT *pProtoTunnel, uint32_t uTunnelId, ProtoTunnelInfoT *pInfo);
|
||||
|
||||
// get module status
|
||||
DIRTYCODE_API int32_t ProtoTunnelStatus(ProtoTunnelRefT *pProtoTunnel, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// control the module
|
||||
DIRTYCODE_API int32_t ProtoTunnelControl(ProtoTunnelRefT *pProtoTunnel, int32_t iControl, int32_t iValue, int32_t iValue2, const void *pValue);
|
||||
|
||||
// update the module
|
||||
DIRTYCODE_API void ProtoTunnelUpdate(ProtoTunnelRefT *pProtoTunnel);
|
||||
|
||||
// use this function to send raw data to a remote host from the prototunnel socket
|
||||
DIRTYCODE_API int32_t ProtoTunnelRawSendto(ProtoTunnelRefT *pProtoTunnel, const char *pBuf, int32_t iLen, const struct sockaddr *pTo, int32_t iToLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _prototunnel_h
|
||||
|
90
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoupnp.h
vendored
Normal file
90
src/thirdparty/dirtysdk/include/DirtySDK/proto/protoupnp.h
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protoupnp.h
|
||||
|
||||
\Description
|
||||
Implements a simple UPnP client, designed specifically to talk to a UPnP
|
||||
router and open up a firewall port for peer-peer communication with a
|
||||
remote client.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2005 Electronic Arts Inc.
|
||||
|
||||
\Version 03/23/2005 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protoupnp_h
|
||||
#define _protoupnp_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoUpnp ProtoUpnp
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// status bits for ProtoUpnpStatus('stat')
|
||||
|
||||
#define PROTOUPNP_STATUS_DISCOVERED (1) //!< discovered a upnp device
|
||||
#define PROTOUPNP_STATUS_DESCRIBED (2) //!< described a upnp device
|
||||
#define PROTOUPNP_STATUS_GOTEXTADDR (4) //!< got external address for device
|
||||
#define PROTOUPNP_STATUS_ADDPORTMAP (8) //!< successfully added port mapping
|
||||
#define PROTOUPNP_STATUS_DELPORTMAP (16) //!< successfully deleted port mapping
|
||||
#define PROTOUPNP_STATUS_FNDPORTMAP (32) //!< found existing port mapping
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! protoupnp macro element definition
|
||||
typedef struct ProtoUpnpMacroT
|
||||
{
|
||||
int32_t iControl;
|
||||
int32_t iValue;
|
||||
int32_t iValue2;
|
||||
void *pValue;
|
||||
} ProtoUpnpMacroT;
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtoUpnpRefT ProtoUpnpRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module
|
||||
DIRTYCODE_API ProtoUpnpRefT *ProtoUpnpCreate(void);
|
||||
|
||||
// get module ref
|
||||
DIRTYCODE_API ProtoUpnpRefT *ProtoUpnpGetRef(void);
|
||||
|
||||
// destroy the module
|
||||
DIRTYCODE_API void ProtoUpnpDestroy(ProtoUpnpRefT *pProtoUpnp);
|
||||
|
||||
// get module status
|
||||
DIRTYCODE_API int32_t ProtoUpnpStatus(ProtoUpnpRefT *pProtoUpnp, int32_t iSelect, void *pBuf, int32_t iBufSize);
|
||||
|
||||
// protoupnp control
|
||||
DIRTYCODE_API int32_t ProtoUpnpControl(ProtoUpnpRefT *pProtoUpnp, int32_t iControl, int32_t iValue, int32_t iValue2, const void *pValue);
|
||||
|
||||
// update the module
|
||||
DIRTYCODE_API void ProtoUpnpUpdate(ProtoUpnpRefT *pProtoUpnp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protoupnp_h
|
||||
|
122
src/thirdparty/dirtysdk/include/DirtySDK/proto/protowebsocket.h
vendored
Normal file
122
src/thirdparty/dirtysdk/include/DirtySDK/proto/protowebsocket.h
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File protowebsocket.h
|
||||
|
||||
\Description
|
||||
This module implements a WebSocket client as documented in RFC 6455
|
||||
(http://tools.ietf.org/html/rfc6455). Note that implementation details
|
||||
may vary when a platform-specific implementation is required. The API
|
||||
as currently implemented offers stream-like operations; message-based
|
||||
operations are currently not supported.
|
||||
|
||||
\Todo
|
||||
- Message-based APIs
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2012 Electronic Arts Inc.
|
||||
|
||||
\Version 11/26/2012 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _protowebsocket_h
|
||||
#define _protowebsocket_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtoWebSocket ProtoWebSocket
|
||||
\Modulemember Proto
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
// close reasons
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_BASE (1000)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_NORMAL (PROTOWEBSOCKET_CLOSEREASON_BASE+0)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_GOINGAWAY (PROTOWEBSOCKET_CLOSEREASON_BASE+1)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_PROTOCOLERROR (PROTOWEBSOCKET_CLOSEREASON_BASE+2)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_UNSUPPORTEDDATA (PROTOWEBSOCKET_CLOSEREASON_BASE+3)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_NOSTATUSRECVD (PROTOWEBSOCKET_CLOSEREASON_BASE+5)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_ABNORMALCLOSURE (PROTOWEBSOCKET_CLOSEREASON_BASE+6)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_INVALIDFRAMEDATA (PROTOWEBSOCKET_CLOSEREASON_BASE+7)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_POLICYVIOLATION (PROTOWEBSOCKET_CLOSEREASON_BASE+8)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_MESSAGETOOBIG (PROTOWEBSOCKET_CLOSEREASON_BASE+9)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_MANDATORYEXT (PROTOWEBSOCKET_CLOSEREASON_BASE+10)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_INTERNALERR (PROTOWEBSOCKET_CLOSEREASON_BASE+11)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_SERVICERESTART (PROTOWEBSOCKET_CLOSEREASON_BASE+12)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_TRYAGAINLATER (PROTOWEBSOCKET_CLOSEREASON_BASE+13)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_TLSHANDSHAKE (PROTOWEBSOCKET_CLOSEREASON_BASE+15)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_MAX (PROTOWEBSOCKET_CLOSEREASON_TLSHANDSHAKE)
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_COUNT (PROTOWEBSOCKET_CLOSEREASON_MAX-PROTOWEBSOCKET_CLOSEREASON_BASE+1)
|
||||
// unidentified close reason
|
||||
#define PROTOWEBSOCKET_CLOSEREASON_UNKNOWN (PROTOWEBSOCKET_CLOSEREASON_BASE+100)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module state definition
|
||||
typedef struct ProtoWebSocketRefT ProtoWebSocketRefT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// allocate a websocket connection and prepare for use
|
||||
DIRTYCODE_API ProtoWebSocketRefT *ProtoWebSocketCreate(int32_t iBufSize);
|
||||
|
||||
// allocate a websocket connection and prepare for use (protossl function signature compatible)
|
||||
DIRTYCODE_API ProtoWebSocketRefT *ProtoWebSocketCreate2(void);
|
||||
|
||||
// destroy a connection and release state
|
||||
DIRTYCODE_API void ProtoWebSocketDestroy(ProtoWebSocketRefT *pWebSocket);
|
||||
|
||||
// initiate a connection to a server
|
||||
DIRTYCODE_API int32_t ProtoWebSocketConnect(ProtoWebSocketRefT *pWebSocket, const char *pUrl);
|
||||
|
||||
// disconnect from the server
|
||||
DIRTYCODE_API int32_t ProtoWebSocketDisconnect(ProtoWebSocketRefT *pWebSocket);
|
||||
|
||||
// send data to a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketSend(ProtoWebSocketRefT *pWebSocket, const char *pBuffer, int32_t iLength);
|
||||
|
||||
// send text data to a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketSendText(ProtoWebSocketRefT *pWebSocket, const char *pBuffer);
|
||||
|
||||
// send a message to a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketSendMessage(ProtoWebSocketRefT *pWebSocket, const char *pBuffer, int32_t iLength);
|
||||
|
||||
// send a text message to a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketSendMessageText(ProtoWebSocketRefT *pWebSocket, const char *pBuffer);
|
||||
|
||||
// recv data from a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketRecv(ProtoWebSocketRefT *pWebSocket, char *pBuffer, int32_t iLength);
|
||||
|
||||
// recv a message from a server over a websocket connection
|
||||
DIRTYCODE_API int32_t ProtoWebSocketRecvMessage(ProtoWebSocketRefT *pWebSocket, char *pBuffer, int32_t iLength);
|
||||
|
||||
// get module status
|
||||
DIRTYCODE_API int32_t ProtoWebSocketStatus(ProtoWebSocketRefT *pWebSocket, int32_t iSelect, void *pBuffer, int32_t iBufSize);
|
||||
|
||||
// control module behavior
|
||||
DIRTYCODE_API int32_t ProtoWebSocketControl(ProtoWebSocketRefT *pWebSocket, int32_t iSelect, int32_t iValue, int32_t iValue2, void *pValue);
|
||||
|
||||
// give time to module to do its thing (should be called periodically to allow module to perform work)
|
||||
DIRTYCODE_API void ProtoWebSocketUpdate(ProtoWebSocketRefT *pWebSocket);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protowebsocket_h
|
||||
|
70
src/thirdparty/dirtysdk/include/DirtySDK/util/aws.h
vendored
Normal file
70
src/thirdparty/dirtysdk/include/DirtySDK/util/aws.h
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File aws.h
|
||||
|
||||
\Description
|
||||
Implements AWS utility functions, including SigV4 signing and signed binary
|
||||
event reading and writing.
|
||||
|
||||
\Copyright
|
||||
Copyright 2018 Electronic Arts
|
||||
|
||||
\Version 12/26/2018 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _aws_h
|
||||
#define _aws_h
|
||||
|
||||
/*!
|
||||
\Moduledef AWS AWS
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! AWS signing info
|
||||
typedef struct AWSSignInfoT
|
||||
{
|
||||
char strRegion[32]; //!< region request is being made in
|
||||
char strService[32]; //!< name of service for request
|
||||
char strKeyPath[64]; //!< keypath for request
|
||||
char strSignature[65]; //!< latest signature, hex encoded
|
||||
char strKey[64]; //!< secret key used to sign request
|
||||
} AWSSignInfoT;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// sign given header with AWS Signature Version 4 signing process
|
||||
DIRTYCODE_API int32_t AWSSignSigV4(char *pHeader, int32_t iHeaderSize, const char *pRequest, const char *pKeyInfo, const char *pService, AWSSignInfoT *pSignInfo);
|
||||
|
||||
// write a signed binary event
|
||||
DIRTYCODE_API int32_t AWSWriteEvent(uint8_t *pBuffer, int32_t iBufSize, const uint8_t *pData, int32_t *pDataSize, const char *pEvent, AWSSignInfoT *pSignInfo);
|
||||
|
||||
// read a signed binary event
|
||||
DIRTYCODE_API int32_t AWSReadEvent(const uint8_t *pBuffer, int32_t iBufLen, char *pEventType, int32_t iEventSize, char *pMessage, int32_t *pMessageSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _aws_h
|
||||
|
||||
|
88
src/thirdparty/dirtysdk/include/DirtySDK/util/base64.h
vendored
Normal file
88
src/thirdparty/dirtysdk/include/DirtySDK/util/base64.h
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
/*H*******************************************************************/
|
||||
/*!
|
||||
\File base64.h
|
||||
|
||||
\Description
|
||||
This module Base-64 encoding/decoding as defined in RFC
|
||||
989, 1040, 1113, 1421, 1521 and 2045.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2003. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 12/11/2003 (SJB) First Version
|
||||
*/
|
||||
/*******************************************************************H*/
|
||||
|
||||
#ifndef _base64_h
|
||||
#define _base64_h
|
||||
|
||||
/*!
|
||||
\Moduledef Base64 Base64
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ***************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines *********************************************************/
|
||||
|
||||
/*** Macros **********************************************************/
|
||||
|
||||
/*! The number of bytes it takes to Base-64 encode the given number
|
||||
of bytes. The result includes any required padding but not a '\0'
|
||||
terminator. */
|
||||
#define Base64EncodedSize(x) ((((x)+2)/3)*4)
|
||||
|
||||
/*! The maximum number of bytes it takes to hold the decoded version
|
||||
of a Base-64 encoded string that is 'x' bytes long.
|
||||
|
||||
In this version of Base-64, 'x' is always a multiple of 4 and the
|
||||
result is always a multiple of 3 (i.e. there may be up to 2 padding
|
||||
bytes at the end of the decoded value). It is assumed that the
|
||||
exact length of the string (minus any padding) is either encoded in
|
||||
the string or is external to the string. */
|
||||
#define Base64DecodedSize(x) (((x)/4)*3)
|
||||
|
||||
/*** Type Definitions ************************************************/
|
||||
|
||||
/*** Variables *******************************************************/
|
||||
|
||||
/*** Functions *******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Base64 encode a string
|
||||
DIRTYCODE_API void Base64Encode(int32_t iInputLen, const char *pInput, char *pOutput);
|
||||
|
||||
// Base64 encode a string, buffer-safe version
|
||||
DIRTYCODE_API int32_t Base64Encode2(const char *pInput, int32_t iInputLen, char *pOutput, int32_t iOutputLen);
|
||||
|
||||
// decode a Base64-encoded string
|
||||
DIRTYCODE_API int32_t Base64Decode(int32_t iInputLen, const char *pInput, char *pOutput);
|
||||
|
||||
// decode a Base64-encoded string, return decoded size
|
||||
DIRTYCODE_API int32_t Base64Decode2(int32_t iInputLen, const char *pInput, char *pOutput);
|
||||
|
||||
// decode a Base64-encoded string, return decoded size, buffer-safe version
|
||||
DIRTYCODE_API int32_t Base64Decode3(const char *pInput, int32_t iInputLen, char *pOutput, int32_t iOutputLen);
|
||||
|
||||
// Base64 encode a url string
|
||||
DIRTYCODE_API int32_t Base64EncodeUrl(const char *pInput, int32_t iInputLen, char *pOutput, int32_t iOutputLen);
|
||||
|
||||
// Base64 encode a url string with more options
|
||||
DIRTYCODE_API int32_t Base64EncodeUrl2(const char *pInput, int32_t iInputLen, char *pOutput, int32_t iOutputLen, uint8_t bPadded);
|
||||
|
||||
// decode a Base64-encode url string
|
||||
DIRTYCODE_API int32_t Base64DecodeUrl(const char *pInput, int32_t iInputLen, char *pOutput, int32_t iOutputLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif
|
55
src/thirdparty/dirtysdk/include/DirtySDK/util/binary7.h
vendored
Normal file
55
src/thirdparty/dirtysdk/include/DirtySDK/util/binary7.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File binary7.h
|
||||
|
||||
\Description
|
||||
This module provides routines to encode/decode binary7 data to/from a buffer.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2009. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 11/02/2009 (cadam) First version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _binary7_h
|
||||
#define _binary7_h
|
||||
|
||||
/*!
|
||||
\Moduledef Binary7 Binary7
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// set a binary field using more efficient encoding
|
||||
DIRTYCODE_API char *Binary7Encode(unsigned char *pDst, int32_t iDstLen, unsigned const char *pSrc, int32_t iSrcLen, uint32_t bTerminate);
|
||||
|
||||
// get binary field contents
|
||||
DIRTYCODE_API unsigned const char *Binary7Decode(unsigned char *pDst, int32_t iDstLen, unsigned const char *pSrc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _binary7_h
|
||||
|
63
src/thirdparty/dirtysdk/include/DirtySDK/util/hpack.h
vendored
Normal file
63
src/thirdparty/dirtysdk/include/DirtySDK/util/hpack.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File hpack.h
|
||||
|
||||
\Description
|
||||
This module implements a decode/encoder based on the HPACK spec
|
||||
(https://tools.ietf.org/html/rfc7541). Which is used for encoding/decoding
|
||||
the HEADERS frame in the HTTP/2 protocol.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2016. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _hpack_h
|
||||
#define _hpack_h
|
||||
|
||||
/*!
|
||||
\Moduledef Hpack Hpack
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct HpackRefT HpackRefT;
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// create the module
|
||||
DIRTYCODE_API HpackRefT *HpackCreate(uint32_t uTableMax, uint8_t bDecoder);
|
||||
|
||||
// destroy the module
|
||||
DIRTYCODE_API void HpackDestroy(HpackRefT *pRef);
|
||||
|
||||
// unpack the header
|
||||
DIRTYCODE_API int32_t HpackDecode(HpackRefT *pRef, const uint8_t *pInput, int32_t iInpSize, char *pOutput, int32_t iOutSize);
|
||||
|
||||
// encode the header
|
||||
DIRTYCODE_API int32_t HpackEncode(HpackRefT *pRef, const char *pInput, uint8_t *pOutput, int32_t iOutSize, uint8_t bHuffman);
|
||||
|
||||
// clear the dynamic table
|
||||
DIRTYCODE_API void HpackClear(HpackRefT *pRef);
|
||||
|
||||
// resize the dynamic table
|
||||
DIRTYCODE_API void HpackResize(HpackRefT *pRef, uint32_t uTableSize, uint8_t bSendUpdate);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _hpack_h
|
98
src/thirdparty/dirtysdk/include/DirtySDK/util/jsonformat.h
vendored
Normal file
98
src/thirdparty/dirtysdk/include/DirtySDK/util/jsonformat.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File jsonformat.h
|
||||
|
||||
\Description
|
||||
This module formats simple Json, in a linear fashion, using a character buffer
|
||||
that the client provides.
|
||||
|
||||
\Notes
|
||||
References:
|
||||
JSON RFC: http://tools.ietf.org/html/rfc4627
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2012.
|
||||
|
||||
\Version 12/11/2012 (jbrookes) First Version
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _jsonformat_h
|
||||
#define _jsonformat_h
|
||||
|
||||
/*!
|
||||
\Moduledef JsonFormat JsonFormat
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
#define JSON_ERR_NONE (0) //!< no error
|
||||
#define JSON_ERR_FULL (-1) //!< buffer is full, no space to add attribute or element.
|
||||
#define JSON_ERR_UNINIT (-2) //!< did not call JsonInit() prior to writing.
|
||||
#define JSON_ERR_NOT_OPEN (-3) //!< attempt to set elem or attrib, but, no tag opened.
|
||||
#define JSON_ERR_ATTR_POSITION (-4) //!< attempt to set an attrib, but, child element already added to tag.
|
||||
#define JSON_ERR_INVALID_PARAM (-5) //!< invalid parameter passed to function
|
||||
|
||||
// Encoding control flags
|
||||
#define JSON_FL_WHITESPACE (1) //!< include formatting whitespace
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the API -- pass in the character buffer. MUST be called first.
|
||||
DIRTYCODE_API void JsonInit(char *pBuffer, int32_t iBufLen, uint8_t uFlags);
|
||||
|
||||
// notify the API that the buf size was increased
|
||||
DIRTYCODE_API void JsonBufSizeIncrease(char *pBuffer, int32_t iNewBufLen);
|
||||
|
||||
// finish JSON output to this buffer; use returned pointer ref
|
||||
DIRTYCODE_API char *JsonFinish(char *pBuffer);
|
||||
|
||||
// start an object
|
||||
DIRTYCODE_API int32_t JsonObjectStart(char *pBuffer, const char *pName);
|
||||
|
||||
// end the current object -- must have an outstanding open object
|
||||
DIRTYCODE_API int32_t JsonObjectEnd(char *pBuffer);
|
||||
|
||||
// start an array
|
||||
DIRTYCODE_API int32_t JsonArrayStart(char *pBuffer, const char *pName);
|
||||
|
||||
// end the current array -- must have an outstanding open array
|
||||
DIRTYCODE_API int32_t JsonArrayEnd(char *pBuffer);
|
||||
|
||||
// add a string element
|
||||
DIRTYCODE_API int32_t JsonAddStr(char *pBuffer, const char *pElemName, const char *pValue);
|
||||
|
||||
// add a number
|
||||
DIRTYCODE_API int32_t JsonAddNum(char *pBuffer, const char *pElemName, const char *pFormatSpec, float fValue);
|
||||
|
||||
// add an integer element
|
||||
DIRTYCODE_API int32_t JsonAddInt(char *pBuffer, const char *pElemName, int64_t iValue);
|
||||
|
||||
// add a date (will be encoded as a string; use JsonAddInteger for integer encoding)
|
||||
DIRTYCODE_API int32_t JsonAddDate(char *pBuffer, const char *pElemName, uint32_t uEpochDate);
|
||||
|
||||
// build a JSON output string from a formatted pattern (like vprintf) $$TODO
|
||||
#ifdef va_start
|
||||
DIRTYCODE_API char *JsonFormatVPrintf(char *pJsonBuff, int32_t iBufLen, const char *pFormat, va_list pFmtArgs);
|
||||
#endif
|
||||
|
||||
// build a JSON output string from a formatted pattern (like printf) $$TODO
|
||||
DIRTYCODE_API char *JsonFormatPrintf(char *pJsonBuff, int32_t iBufLen, const char *pFormat, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _jsonformat_h
|
98
src/thirdparty/dirtysdk/include/DirtySDK/util/jsonparse.h
vendored
Normal file
98
src/thirdparty/dirtysdk/include/DirtySDK/util/jsonparse.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File jsonparse.h
|
||||
|
||||
\Description
|
||||
A simple JSON parser.
|
||||
|
||||
\Notes
|
||||
Written by Greg Schaefer outside of EA for a personal project, but donated
|
||||
back for a good cause.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2012.
|
||||
|
||||
\Version 12/11/2012 (jbrookes) Added to DirtySDK, added some new functionality
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _jsonparse_h
|
||||
#define _jsonparse_h
|
||||
|
||||
/*!
|
||||
\Moduledef JsonParse JsonParse
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
//! alternate name for JsonSeekObjectEnd (DEPRECATED)
|
||||
#define JsonGetListItemEnd(__pObject) JsonSeekObjectEnd(__pObject)
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// parse json, preparing lookup for fast dereference
|
||||
DIRTYCODE_API int32_t JsonParse(uint16_t *pDst, int32_t iMax, const char *pSrc, int32_t iLen);
|
||||
|
||||
// parse json, allocate required memory for parse buffer internally
|
||||
DIRTYCODE_API uint16_t *JsonParse2(const char *pSrc, int32_t iLen, int32_t iMemModule, int32_t iMemGroup, void *pMemGroupUserData);
|
||||
|
||||
// locate a json element
|
||||
DIRTYCODE_API const char *JsonFind(const uint16_t *pParse, const char *pName);
|
||||
|
||||
// locate a json element, starting from an offset, with an optional array index
|
||||
DIRTYCODE_API const char *JsonFind2(const uint16_t *pParse, const char *pJson, const char *pName, int32_t iIndex);
|
||||
|
||||
// get a string element
|
||||
DIRTYCODE_API int32_t JsonGetString(const char *pJson, char *pBuffer, int32_t iLength, const char *pDefault);
|
||||
|
||||
// get a string element, with accumulating error
|
||||
DIRTYCODE_API int32_t JsonGetString2(const char *pJson, char *pBuffer, int32_t iLength, const char *pDefault, uint8_t *pError);
|
||||
|
||||
// get an integer element
|
||||
DIRTYCODE_API int64_t JsonGetInteger(const char *pJson, int64_t iDefault);
|
||||
|
||||
// get an integer element, with range validation and accumulating error
|
||||
DIRTYCODE_API int64_t JsonGetInteger2(const char *pJson, int64_t iDefault, int64_t iMin, int64_t iMax, uint8_t *pError);
|
||||
|
||||
// get a date in ISO_8601 format
|
||||
DIRTYCODE_API uint32_t JsonGetDate(const char *pJson, uint32_t uDefault);
|
||||
|
||||
// get a date in ISO_8601 format, with accumulating error
|
||||
DIRTYCODE_API uint32_t JsonGetDate2(const char *pJson, uint32_t uDefault, uint8_t *pError);
|
||||
|
||||
// get a boolean element
|
||||
DIRTYCODE_API uint8_t JsonGetBoolean(const char *pJson, uint8_t bDefault);
|
||||
|
||||
// get a boolean element, with accumulating error
|
||||
DIRTYCODE_API uint8_t JsonGetBoolean2(const char *pJson, uint8_t bDefault, uint8_t *pError);
|
||||
|
||||
// get an enum element
|
||||
DIRTYCODE_API int32_t JsonGetEnum(const char *pJson, const char *pEnumArray[], int32_t iDefault);
|
||||
|
||||
// get an enum element, with accumulating error
|
||||
DIRTYCODE_API int32_t JsonGetEnum2(const char *pJson, const char *pEnumArray[], int32_t iDefault, uint8_t *pError);
|
||||
|
||||
// seek to the end of an object within the JSON text buffer
|
||||
DIRTYCODE_API const char *JsonSeekObjectEnd(const char *pObject);
|
||||
|
||||
// seek to the start of the value of a key / value pair within the JSON text buffer
|
||||
DIRTYCODE_API const char *JsonSeekValue(const char *pKey);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _jsonparse_h
|
79
src/thirdparty/dirtysdk/include/DirtySDK/util/murmurhash3.h
vendored
Normal file
79
src/thirdparty/dirtysdk/include/DirtySDK/util/murmurhash3.h
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
/*H********************************************************************************/
|
||||
/*!
|
||||
\File murmurhash3.h
|
||||
|
||||
\Description
|
||||
An implementation of MurmurHash3, based heavily on the x64 128bit output
|
||||
implementation. MurmurHash3 is a public domain hashing algorithm written
|
||||
by Austin Appleby, ref http://code.google.com/p/smhasher/wiki/MurmurHash3.
|
||||
|
||||
MurmurHash3 is not cryptographically secure, however it has excellent
|
||||
collision resistance and is orders of magnitude faster than the fastest
|
||||
secure cryptographic hash.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2014 Electronic Arts
|
||||
|
||||
\Version 03/07/2014 (jbrookes) First Version
|
||||
*/
|
||||
/********************************************************************************H*/
|
||||
|
||||
#ifndef _murmurhash3_h
|
||||
#define _murmurhash3_h
|
||||
|
||||
/*!
|
||||
\Moduledef MurmurHash3 MurmurHash3
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ****************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
#define MURMURHASH_HASHSIZE (16)
|
||||
|
||||
/*** Macros ***********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
|
||||
typedef struct MurmurHash3T
|
||||
{
|
||||
uint64_t aState[2]; //!< hash state
|
||||
int32_t iCount; //!< total byte count
|
||||
uint8_t aData[16]; //!< partial data block
|
||||
} MurmurHash3T;
|
||||
|
||||
/*** Variables ********************************************************************/
|
||||
|
||||
/*** Functions ********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// init the MurmurHash3 context
|
||||
DIRTYCODE_API void MurmurHash3Init(MurmurHash3T *pContext);
|
||||
|
||||
// init the MurmurHash3 context, with hash size
|
||||
DIRTYCODE_API void MurmurHash3Init2(MurmurHash3T *pContext, int32_t iHashSize);
|
||||
|
||||
// add data to the MurmurHash3 context (hash the data)
|
||||
DIRTYCODE_API void MurmurHash3Update(MurmurHash3T *pContext, const void *pBuffer, int32_t iLength);
|
||||
|
||||
// convert MurmurHash3 state into final output form
|
||||
DIRTYCODE_API void MurmurHash3Final(MurmurHash3T *pContext, void *pBuffer, int32_t iLength);
|
||||
|
||||
// hash the data, all-in-one version
|
||||
DIRTYCODE_API void MurmurHash3(void *_pOutput, int32_t iOutLen, const void *_pInput, int32_t iInpLen, const void *pKey, int32_t iKeyLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _murmurhash3_h
|
||||
|
59
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufcommon.h
vendored
Normal file
59
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufcommon.h
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File protobufcommon.h
|
||||
|
||||
\Description
|
||||
Shared definitions and functionality for the protobuf encoder / decoder
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017-2018. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 07/05/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _protobufcommon_h
|
||||
#define _protobufcommon_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtobufCommon ProtobufCommon
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include Files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! different field types that are supported by protobuf. note, the order is needed to follow the defined values of the protocol
|
||||
typedef enum ProtobufTypeE
|
||||
{
|
||||
PROTOBUF_TYPE_VARINT, //!< int32, int64, uint32, uint64, sint32, sint64, bool, enum
|
||||
PROTOBUF_TYPE_64BIT, //!< fixed64 (uint64_t), sfixed64 (int64_t), double
|
||||
PROTOBUF_TYPE_LENGTH_DELIMITED, //!< string, bytes, embedded messages, packed repeated fields
|
||||
PROTOBUF_TYPE_START_GROUP, //!< groups (deprecated)
|
||||
PROTOBUF_TYPE_END_GROUP, //!< groups (deprecated)
|
||||
PROTOBUF_TYPE_32BIT //!< fixed32 (uint32_t), sfixed32 (int32_t), float
|
||||
} ProtobufTypeE;
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// read the message size out of the payload
|
||||
DIRTYCODE_API const uint8_t *ProtobufCommonReadSize(const uint8_t *pBuffer, int32_t iBufLen, int32_t *pResult);
|
||||
|
||||
// get the string representation of a type
|
||||
DIRTYCODE_API const char *ProtobufCommonGetType(ProtobufTypeE eType);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protobufcommon_h
|
113
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufread.h
vendored
Normal file
113
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufread.h
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File protobufread.h
|
||||
|
||||
\Description
|
||||
Interface of decoder for the Google Protobuf wire format
|
||||
See: https://developers.google.com/protocol-buffers/docs/encoding
|
||||
|
||||
This module only supports protobuf version 3, if any lesser versions are used
|
||||
the result is undefined.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017-2018. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 07/05/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _protobufread_h
|
||||
#define _protobufread_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtobufRead ProtobufRead
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Includes **************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! struct for ease of use for the API
|
||||
typedef struct ProtobufReadT
|
||||
{
|
||||
const uint8_t *pBuffer; //!< pointer to the start of the buffer
|
||||
const uint8_t *pBufEnd; //!< pointer to the end of the buffer
|
||||
} ProtobufReadT;
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initialize the state
|
||||
DIRTYCODE_API void ProtobufReadInit(ProtobufReadT *pState, const uint8_t *pBuffer, int32_t iBufLen);
|
||||
|
||||
// find a field by identifier
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadFind(const ProtobufReadT *pState, uint32_t uField);
|
||||
|
||||
// find a field by identifier that allows continuation for non-packed repeated fields
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadFind2(const ProtobufReadT *pState, uint32_t uField, const uint8_t *pBuffer);
|
||||
|
||||
// read the current field header
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadHeader(const ProtobufReadT *pState, const uint8_t *pCurrent, uint32_t *pField, uint8_t *pType);
|
||||
|
||||
// skip over a field
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadSkip(const ProtobufReadT *pState, const uint8_t *pCurrent, uint8_t uType);
|
||||
|
||||
// read the varint int32, int64, uint32, uint64, bool or enum from the buffer
|
||||
DIRTYCODE_API uint64_t ProtobufReadVarint(const ProtobufReadT *pState, const uint8_t *pCurrent);
|
||||
|
||||
// alternative version used in conjunction with repeated field reading
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadVarint2(const ProtobufReadT *pState, const uint8_t *pCurrent, uint64_t *pResult);
|
||||
|
||||
// read the repeated varint int32, int64, uint32, uint64, bool or enum from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadRepeatedVarint(const ProtobufReadT *pState, const uint8_t *pCurrent, uint64_t *pResult, int32_t iCount);
|
||||
|
||||
// read the varint sint32 from the buffer (zigzag decoded)
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadSint32(const ProtobufReadT *pState, const uint8_t *pCurrent, int32_t *pResult);
|
||||
|
||||
// read the repeated varint sint32 from the buffer (zigzag decoded)
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadRepeatedSint32(const ProtobufReadT *pState, const uint8_t *pCurrent, int32_t *pResult, int32_t iCount);
|
||||
|
||||
// read the varint sint64 from the buffer (zigzag decoded)
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadSint64(const ProtobufReadT *pState, const uint8_t *pCurrent, int64_t *pResult);
|
||||
|
||||
// read the repeated varint sint64 from the buffer (zigzag decoded)
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadRepeatedSint64(const ProtobufReadT *pState, const uint8_t *pCurrent, int64_t *pResult, int32_t iCount);
|
||||
|
||||
// read fixed32, float or sfixed32 from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadFixed32(const ProtobufReadT *pState, const uint8_t *pCurrent, void *pOutput);
|
||||
|
||||
// read repeated fixed32, float or sfixed32 from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadRepeatedFixed32(const ProtobufReadT *pState, const uint8_t *pCurrent, void *pOutput, int32_t iOutLen);
|
||||
|
||||
// read fixed64, double or sfixed64 from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadFixed64(const ProtobufReadT *pState, const uint8_t *pCurrent, void *pOutput);
|
||||
|
||||
// read repeated fixed64, double or sfixed64 from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadRepeatedFixed64(const ProtobufReadT *pState, const uint8_t *pCurrent, void *pOutput, int32_t iOutLen);
|
||||
|
||||
// read the bytes from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadBytes(const ProtobufReadT *pState, const uint8_t *pCurrent, uint8_t *pOutput, int32_t iOutLen);
|
||||
|
||||
// read the string from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadString(const ProtobufReadT *pState, const uint8_t *pCurrent, char *pOutput, int32_t iOutLen);
|
||||
|
||||
// read an embedded message information from the buffer
|
||||
DIRTYCODE_API const uint8_t *ProtobufReadMessage(const ProtobufReadT *pState, const uint8_t *pCurrent, ProtobufReadT *pMsg);
|
||||
|
||||
// read the number of elements in the repeated field
|
||||
DIRTYCODE_API int32_t ProtobufReadNumRepeatedElements(const ProtobufReadT *pState, uint32_t uField, uint8_t uType);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protobufread_h
|
105
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufwrite.h
vendored
Normal file
105
src/thirdparty/dirtysdk/include/DirtySDK/util/protobufwrite.h
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
/*H*************************************************************************************/
|
||||
/*!
|
||||
\File protobufwrite.h
|
||||
|
||||
\Description
|
||||
Interface of encoder for the Google Protobuf wire format
|
||||
See: https://developers.google.com/protocol-buffers/docs/encoding
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Electronic Arts 2017-2018. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 07/05/2017 (eesponda)
|
||||
*/
|
||||
/*************************************************************************************H*/
|
||||
|
||||
#ifndef _protobufwrite_h
|
||||
#define _protobufwrite_h
|
||||
|
||||
/*!
|
||||
\Moduledef ProtobufWrite ProtobufWrite
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Includes **************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! used for result for the write functions
|
||||
typedef enum ProtobufWriteErrorE
|
||||
{
|
||||
PROTOBUFWRITE_ERROR_OK, //!< successful operation
|
||||
PROTOBUFWRITE_ERROR_FULL, //!< the buffer is full
|
||||
PROTOBUFWRITE_ERROR_EMBED, //!< called begin when out of slots or calling end when begin hasn't been called
|
||||
} ProtobufWriteErrorE;
|
||||
|
||||
//! opaque module ref
|
||||
typedef struct ProtobufWriteRefT ProtobufWriteRefT;
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// initialize the encoder, must be called first
|
||||
DIRTYCODE_API ProtobufWriteRefT *ProtobufWriteCreate(uint8_t *pBuffer, int32_t iBufLen, uint8_t bEncodeSize);
|
||||
|
||||
// write the varint int32, int64, uint32, uint64, bool or enum to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteVarint(ProtobufWriteRefT *pState, uint64_t uValue, uint32_t uField);
|
||||
|
||||
// write repeated varint to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteRepeatedVarint(ProtobufWriteRefT *pState, uint64_t *pValues, int32_t iCount, uint32_t uField);
|
||||
|
||||
// write the varint sint32 to the buffer (zigzag encoded)
|
||||
DIRTYCODE_API int32_t ProtobufWriteSint32(ProtobufWriteRefT *pState, int32_t iValue, uint32_t uField);
|
||||
|
||||
// write repeated varint sint32 to the buffer (zigzag encoded)
|
||||
DIRTYCODE_API int32_t ProtobufWriteRepeatedSint32(ProtobufWriteRefT *pState, int32_t *pValues, int32_t iCount, uint32_t uField);
|
||||
|
||||
// write the varint sint64 to the buffer (zigzag encoded)
|
||||
DIRTYCODE_API int32_t ProtobufWriteSint64(ProtobufWriteRefT *pState, int64_t iValue, uint32_t uField);
|
||||
|
||||
// write repeated varint sint64 to the buffer (zigzag encoded)
|
||||
DIRTYCODE_API int32_t ProtobufWriteRepeatedSint64(ProtobufWriteRefT *pState, int64_t *pValues, int32_t iCount, uint32_t uField);
|
||||
|
||||
// write fixed32, float or sfixed32 to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteFixed32(ProtobufWriteRefT *pState, const void *pValue, uint32_t uField);
|
||||
|
||||
// write repeated fixed32, float or sfixed32 to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteRepeatedFixed32(ProtobufWriteRefT *pState, const void *pInput, int32_t iInpLen, uint32_t uField);
|
||||
|
||||
// write fixed64, double or sfixed64 to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteFixed64(ProtobufWriteRefT *pState, const void *pValue, uint32_t uField);
|
||||
|
||||
// write repeated fixed64, double or sfixed64 to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteRepeatedFixed64(ProtobufWriteRefT *pState, const void *pInput, int32_t iInpLen, uint32_t uField);
|
||||
|
||||
// write the length delimited string, bytes or embedded message/packed repeated fields (if already encoded in pValue) to the buffer
|
||||
DIRTYCODE_API int32_t ProtobufWriteLengthDelimited(ProtobufWriteRefT *pState, const void *pValue, int32_t iLength, uint32_t uField);
|
||||
|
||||
// alias function to write string
|
||||
#define ProtobufWriteString(pState, pValue, iLength, uField) ProtobufWriteLengthDelimited(pState, pValue, iLength, uField)
|
||||
|
||||
// alias function to write bytes
|
||||
#define ProtobufWriteBytes(pState, pValue, iLength, uField) ProtobufWriteLengthDelimited(pState, pValue, iLength, uField)
|
||||
|
||||
// begin an embedded message/packed repeated fields
|
||||
DIRTYCODE_API int32_t ProtobufWriteMessageBegin(ProtobufWriteRefT *pState, uint32_t uField);
|
||||
|
||||
// end an embedded message/packed repeated fields
|
||||
DIRTYCODE_API int32_t ProtobufWriteMessageEnd(ProtobufWriteRefT *pState);
|
||||
|
||||
// finish the writing of the message, cleanup the module state and return the size of the payload
|
||||
DIRTYCODE_API int32_t ProtobufWriteDestroy(ProtobufWriteRefT *pState);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _protobufwrite_h
|
101
src/thirdparty/dirtysdk/include/DirtySDK/util/utf8.h
vendored
Normal file
101
src/thirdparty/dirtysdk/include/DirtySDK/util/utf8.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File utf8.h
|
||||
|
||||
\Description
|
||||
This module implements routines for converting to and from UTF-8.
|
||||
|
||||
\Notes
|
||||
This code only decodes the first three octets of UTF-8, thus it only handles UCS-2 codes,
|
||||
not UCS-4 codes. It also does not handle UTF-16 (and surrogate pairs), and is therefore
|
||||
limited to encoding to/decoding from the basic reference plane.
|
||||
|
||||
Helpful references:
|
||||
|
||||
http://www.utf-8.com/ - links
|
||||
http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc2279.html - RFC 2279
|
||||
http://www.unicode.org/charts/ - UNICODE character charts
|
||||
http://www-106.ibm.com/developerworks/library/utfencodingforms/ - UNICODE primer
|
||||
http://www.columbia.edu/kermit/utf8.html - UTF-8 samples
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2003. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 03/25/03 (JLB) First version.
|
||||
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _utf8_h
|
||||
#define _utf8_h
|
||||
|
||||
/*!
|
||||
\Moduledef Utf8 Utf8
|
||||
\Modulemember Util
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files *********************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
|
||||
/*** Defines ***************************************************************************/
|
||||
|
||||
/*** Macros ****************************************************************************/
|
||||
|
||||
/*** Type Definitions ******************************************************************/
|
||||
|
||||
//! UTF-8 to 8bit translation table
|
||||
typedef struct Utf8TransTblT
|
||||
{
|
||||
uint32_t uRangeBegin;
|
||||
uint32_t uRangeEnd;
|
||||
unsigned char *pCodeTbl;
|
||||
} Utf8TransTblT;
|
||||
|
||||
//! 8bit to UTF-8 translation table
|
||||
typedef struct Utf8EncodeTblT
|
||||
{
|
||||
uint16_t uCodeTbl[256];
|
||||
} Utf8EncodeTblT;
|
||||
|
||||
/*** Variables *************************************************************************/
|
||||
|
||||
/*** Functions *************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// strip non-ASCII characters from a UTF-8 encoded string
|
||||
DIRTYCODE_API int32_t Utf8Strip(char *pOutStr, int32_t iBufSize, const char *pInStr);
|
||||
|
||||
// replace non-ASCII characters in a UTF-8 encoded string with 'cReplace'
|
||||
DIRTYCODE_API int32_t Utf8Replace(char *pOutStr, int32_t iBufSize, const char *pInStr, char cReplace);
|
||||
|
||||
// get code point length of UTF-8 encoded string
|
||||
DIRTYCODE_API int32_t Utf8StrLen(const char *pStr);
|
||||
|
||||
// encode a UCS-2 string to UTF-8
|
||||
DIRTYCODE_API int32_t Utf8EncodeFromUCS2(char *pOutStr, int32_t iBufLen, const uint16_t *pInStr);
|
||||
|
||||
// encode a single UCS-2 "char" to UTF-8 string.
|
||||
DIRTYCODE_API int32_t Utf8EncodeFromUCS2CodePt(char *pOutPtr, uint16_t uCodePt);
|
||||
|
||||
// decode a UTF-8 encoded string into UCS-2
|
||||
DIRTYCODE_API int32_t Utf8DecodeToUCS2(uint16_t *pOutStr, int32_t iBufLen, const char *pInStr);
|
||||
|
||||
// encode the given 8bit input string to UTF-8, based on the input translation table
|
||||
DIRTYCODE_API int32_t Utf8EncodeFrom8Bit(char *pOutStr, int32_t iBufLen, const char *pInStr, const Utf8EncodeTblT *pEncodeTbl);
|
||||
|
||||
// translate the given UTF-8 sequence based on the NULL-terminated array of given tables
|
||||
DIRTYCODE_API int32_t Utf8TranslateTo8Bit(char *pOutStr, int32_t iBufLen, const char *pInStr, char cReplace, const Utf8TransTblT *pTransTbl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _utf8_h
|
100
src/thirdparty/dirtysdk/include/DirtySDK/voip/voip.h
vendored
Normal file
100
src/thirdparty/dirtysdk/include/DirtySDK/voip/voip.h
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
|
||||
\File voip.h
|
||||
|
||||
\Description
|
||||
Main include for Voice Over IP module.
|
||||
|
||||
\Notes
|
||||
MLU:
|
||||
Every Local User should be registered with the voip subsytem in order to get headset status info with VoipSetLocalUser().
|
||||
In order to get fully functional voip a user must be further activated which enrolls them as a participating user with VoipGroupActivateLocalUser().
|
||||
|
||||
Basically any users that are being pulled into the game should be a participating user.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) Tiburon Entertainment / Electronic Arts 2002-2004. ALL RIGHTS RESERVED.
|
||||
|
||||
\Version 1.0 11/19/02 (IRS) First Version
|
||||
\Version 2.0 05/13/03 (GWS) Rewrite to fix misc bugs and improve network connection.
|
||||
\Version 3.0 11/03/03 (JLB) Implemented unloadable support, major code cleanup and reorganization.
|
||||
\Version 3.5 03/02/04 (JLB) VoIP 2.0 - API changes for future multiple channel support.
|
||||
\Version 3.6 11/19/08 (mclouatre) Modified synopsis of VoipStatus()
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _voip_h
|
||||
#define _voip_h
|
||||
|
||||
/*!
|
||||
\Moduledef VoipApi VoipApi
|
||||
\Modulemember Voip
|
||||
*/
|
||||
//@{
|
||||
|
||||
/*** Include files ********************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/voip/voipdef.h"
|
||||
|
||||
/*** Defines **************************************************************************************/
|
||||
|
||||
/*** Macros ***************************************************************************************/
|
||||
|
||||
/*** Type Definitions *****************************************************************************/
|
||||
|
||||
/*** Variables ************************************************************************************/
|
||||
|
||||
/*** Functions ************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// prepare voip for use
|
||||
DIRTYCODE_API VoipRefT *VoipStartup(int32_t iMaxPeers, int32_t iData);
|
||||
|
||||
// return pointer to current module state
|
||||
DIRTYCODE_API VoipRefT *VoipGetRef(void);
|
||||
|
||||
// release all voip resources
|
||||
DIRTYCODE_API void VoipShutdown(VoipRefT *pVoip, uint32_t uShutdownFlags);
|
||||
|
||||
// register/unregister specified local user with the voip sub-system (allows for local headset status query, but not voice acquisition/playback)
|
||||
DIRTYCODE_API void VoipSetLocalUser(VoipRefT *pVoip, int32_t iLocalUserIndex, uint32_t bRegister);
|
||||
|
||||
// return information about local hardware state on a per-user basis
|
||||
DIRTYCODE_API int32_t VoipLocalUserStatus(VoipRefT *pVoip, int32_t iLocalUserIndex);
|
||||
|
||||
// return status
|
||||
DIRTYCODE_API int32_t VoipStatus(VoipRefT *pVoip, int32_t iSelect, int32_t iValue, void *pBuf, int32_t iBufSize); //do any of the controls need user index?
|
||||
|
||||
// set control options
|
||||
DIRTYCODE_API int32_t VoipControl(VoipRefT *pVoip, int32_t iControl, int32_t iValue, void *pValue); //do any of the controls need user index?
|
||||
|
||||
// set speaker output callback (only available on some platforms)
|
||||
DIRTYCODE_API void VoipSpkrCallback(VoipRefT *pVoip, VoipSpkrCallbackT *pCallback, void *pUserData);
|
||||
|
||||
// pick a channel
|
||||
DIRTYCODE_API int32_t VoipSelectChannel(VoipRefT *pVoip, int32_t iUserIndex, int32_t iChannel, VoipChanModeE eMode);
|
||||
|
||||
// go back to not using channels
|
||||
DIRTYCODE_API void VoipResetChannels(VoipRefT *pVoip, int32_t iUserIndex);
|
||||
|
||||
// config voice transcriptions (for default config set uProfile to -1)
|
||||
DIRTYCODE_API void VoipConfigTranscription(VoipRefT *pVoip, uint32_t uProfile, const char *pUrl, const char *pKey);
|
||||
|
||||
// config text narration (for the default config set uProvider to -1)
|
||||
DIRTYCODE_API void VoipConfigNarration(VoipRefT *pVoip, uint32_t uProvider, const char *pUrl, const char *pKey);
|
||||
|
||||
// set first party id callback
|
||||
DIRTYCODE_API void VoipRegisterFirstPartyIdCallback(VoipRefT *pVoip, VoipFirstPartyIdCallbackCbT *pCallback, void *pUserData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif // _voip_h
|
||||
|
62
src/thirdparty/dirtysdk/include/DirtySDK/voip/voipblocklist.h
vendored
Normal file
62
src/thirdparty/dirtysdk/include/DirtySDK/voip/voipblocklist.h
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
/*H*************************************************************************************************/
|
||||
/*!
|
||||
\File voipblocklist.h
|
||||
|
||||
\Description
|
||||
Allow blocking of voip communication based on account id.
|
||||
|
||||
\Copyright
|
||||
Copyright (c) 2019 Electronic Arts Inc.
|
||||
|
||||
\Version 07/03/2019 (cvienneau) First Version
|
||||
*/
|
||||
/*************************************************************************************************H*/
|
||||
|
||||
#ifndef _voipblocklist_h
|
||||
#define _voipblocklist_h
|
||||
|
||||
/*** Include files ********************************************************************************/
|
||||
|
||||
#include "DirtySDK/platform.h"
|
||||
#include "DirtySDK/voip/voipdef.h"
|
||||
|
||||
/*** Defines **********************************************************************/
|
||||
|
||||
/*** Type Definitions *************************************************************/
|
||||
typedef struct VoipBlockListT VoipBlockListT;
|
||||
|
||||
/*** Macros ***************************************************************************************/
|
||||
|
||||
/*** Variables ************************************************************************************/
|
||||
|
||||
/*** Functions ************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// creates the VoipBlockListT (internal use only by voipcommon)
|
||||
DIRTYCODE_API VoipBlockListT *VoipBlockListCreate(void);
|
||||
|
||||
// destroys the VoipBlockListT (internal use only by voipcommon)
|
||||
DIRTYCODE_API void VoipBlockListDestroy(VoipRefT *pVoip);
|
||||
|
||||
// add a user to be blocked by the local user
|
||||
DIRTYCODE_API uint8_t VoipBlockListAdd(VoipRefT *pVoip, int32_t iLocalUserIndex, int64_t iMutedAccountId);
|
||||
|
||||
// remove a user that was blocked by the local user
|
||||
DIRTYCODE_API uint8_t VoipBlockListRemove(VoipRefT *pVoip, int32_t iLocalUserIndex, int64_t iMutedAccountId);
|
||||
|
||||
// check if a user is blocked by the local user
|
||||
DIRTYCODE_API uint8_t VoipBlockListIsBlocked(VoipRefT *pVoip, int32_t iLocalUserIndex, int64_t iMutedAccountId);
|
||||
|
||||
// clear the blocked list for the local user (-1 for all users)
|
||||
DIRTYCODE_API uint8_t VoipBlockListClear(VoipRefT *pVoip, int32_t iLocalUserIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _voipblocklist_h
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user