Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,199 @@
/*------------------------------------------------------------------------------
FILE : DynArray.h
CREATED : 97/12/02
AUTHOR : Catalin Cocos
CONTENTS: dynamic pointer array with sorting capabilities
------------------------------------------------------------------------------*/
#ifndef __DMS_DYN_ARRAY__
#define __DMS_DYN_ARRAY__
/*
* To export code.
*/
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
/*------------------------------------------------------------------------------
TYPES
------------------------------------------------------------------------------*/
typedef struct LDT_tdst_DSArray_ LDT_tdst_DSArray;
struct LDT_tdst_DSArray_
{
void** pData; /*the array of pointers*/
int nSize; /*the size of the array*/
int nMaxSize; /*the allocated size*/
int nGrowBy;
int nSortKey; /*the key to sort the array by*/
int (* pfnCompare)(const void**, const void** ); /*the comparison function*/
};
/*------------------------------------------------------------------------------
FUNCTIONS
------------------------------------------------------------------------------*/
/*creation, initialization, deletion
--------------------------------------*/
CPA_EXPORT LDT_tdst_DSArray* LDT_DSAr_new(); /* creates a new array */
CPA_EXPORT int LDT_DSAr_Init( LDT_tdst_DSArray* ); /* initializes an array */
CPA_EXPORT void LDT_DSAr_delete( LDT_tdst_DSArray* ); /* deletes an existing array*/
CPA_EXPORT void LDT_DSAr_SetGranularity(LDT_tdst_DSArray*, int);
CPA_EXPORT void LDT_DSAr_SetSortMethod(LDT_tdst_DSArray*, int (*)(const void**, const void** ));
/* standard pointer array functionality
-----------------------------------------*/
/* Attributes */
CPA_EXPORT int LDT_DSAr_GetSize( LDT_tdst_DSArray* );
CPA_EXPORT int LDT_DSAr_GetUpperBound( LDT_tdst_DSArray* );
CPA_EXPORT int LDT_DSAr_SetSize( LDT_tdst_DSArray*, int nNewSize );
/* Operations */
/* Clean up */
CPA_EXPORT void LDT_DSAr_FreeExtra( LDT_tdst_DSArray* );
CPA_EXPORT void LDT_DSAr_RemoveAll( LDT_tdst_DSArray* );
/* Accessing elements */
CPA_EXPORT void* LDT_DSAr_GetAt(LDT_tdst_DSArray*, int nIndex);
CPA_EXPORT void LDT_DSAr_SetAt(LDT_tdst_DSArray*, int nIndex, void* newElement);
CPA_EXPORT void** LDT_DSAr_ElementAt(LDT_tdst_DSArray*, int nIndex);
/* Potentially growing the array */
CPA_EXPORT int LDT_DSAr_Add(LDT_tdst_DSArray*, void* newElement);
/* Operations that move elements around */
CPA_EXPORT int LDT_DSAr_InsertAt(LDT_tdst_DSArray*, int nIndex, void* newElement );
CPA_EXPORT void* LDT_DSAr_RemoveAt(LDT_tdst_DSArray*, int nIndex );
CPA_EXPORT int LDT_DSAr_InsertArrayAt(LDT_tdst_DSArray*, int nStartIndex, LDT_tdst_DSArray* pNewArray);
/* sorting facilities
------------------------*/
/* Sorting elements */
CPA_EXPORT void LDT_DSAr_QSort( LDT_tdst_DSArray* );
/* Adding elements */
CPA_EXPORT int LDT_DSAr_SAdd( LDT_tdst_DSArray*, void* newElement, int AdmitDuplicates, int* position );
/* Searching elements */
CPA_EXPORT int LDT_DSAr_Index( LDT_tdst_DSArray*, void* newElement, int *p_iidx );
CPA_EXPORT int LDT_DSAr_UpperBound( LDT_tdst_DSArray*, int idx);
CPA_EXPORT int LDT_DSAr_LowerBound( LDT_tdst_DSArray*, int idx);
/*------------------------------------------------------------------------------
INLINE FUNCTIONS IMPLEMENTATION
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
DESC. : sets the array's granularity
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void LDT_DSAr_SetGranularity(LDT_tdst_DSArray* pst_Ar, int _nGrowBy )
{
pst_Ar->nGrowBy = ( 0>_nGrowBy? 0: _nGrowBy );
}
/*------------------------------------------------------------------------------
DESC. : sets the array's sort method. If NULL, the array's sort functions
are not effective.
WARNING : The sort method must be set prior to the use of any sort-related
functions.
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void LDT_DSAr_SetSortMethod(LDT_tdst_DSArray* pst_Ar,
int (*_pfnCompare)(const void**, const void** ))
{
pst_Ar->pfnCompare = _pfnCompare;
}
/*------------------------------------------------------------------------------
DESC. : gets the array's number of elements
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline int LDT_DSAr_GetSize( LDT_tdst_DSArray* pst_Ar )
{
return pst_Ar->nSize;
}
/*------------------------------------------------------------------------------
DESC. : gets the array's upper bound (maximum index)
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline int LDT_DSAr_GetUpperBound( LDT_tdst_DSArray* pst_Ar )
{
return pst_Ar->nSize-1;
}
/*------------------------------------------------------------------------------
DESC. : sets the array's size. - returns 1 if successful, 0 on error;
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void LDT_DSAr_RemoveAll( LDT_tdst_DSArray* pst_Ar )
{
LDT_DSAr_SetSize( pst_Ar, 0 ); /* clean-up */
}
/*------------------------------------------------------------------------------
DESC. : Gets the value of an array element. returns NULL on error
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void* LDT_DSAr_GetAt(LDT_tdst_DSArray* pst_Ar, int nIndex)
{
if(nIndex < 0 || nIndex >= pst_Ar->nSize) return NULL;
return pst_Ar->pData[nIndex];
}
/*------------------------------------------------------------------------------
DESC. : Sets an array element. If the index is out of bounds, nothing happens
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void LDT_DSAr_SetAt(LDT_tdst_DSArray* pst_Ar, int nIndex, void* newElement)
{
if(nIndex < 0 || nIndex >= pst_Ar->nSize) return;
pst_Ar->pData[nIndex] = newElement;
}
/*------------------------------------------------------------------------------
DESC. : Gets an array element. returns NULL on error
CREATED : 97/12/02
AUTHOR : Catalin Cocos
------------------------------------------------------------------------------*/
__inline void** LDT_DSAr_ElementAt(LDT_tdst_DSArray* pst_Ar, int nIndex)
{
if(nIndex < 0 || nIndex >= pst_Ar->nSize) return NULL;
return pst_Ar->pData + nIndex;
}
#endif/*__DMS_DYN_ARRAY__*/

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////
//
// Management of the Module : LDT
//
// File Name : ErrLDT.h
// Date :
// Author : CPA_Ed_1 team
//
/////////////////////////////////////////////////////////////
//
// abbreviation of the module-name. Used in macro is 'LDT'
//
/////////////////////////////////////////////////////////////
#ifndef __ERRLDT_H__
#define __ERRLDT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define C_szLDTVersion "LDT V1.0.0" /* The format is LDT Va.b.c with LDT is the Tag of the module */
#define C_szLDTFullName "LDT Module"/* the complete and clear name of the module */
#define C_szLDTDate __DATE__ /*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
/* For DLLs who are using this module : */
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#include "ERM.h"
//------------------
// Global Variables
//------------------
#undef __ERRLDT_EXTERN
#ifndef __DeclareGlobalVariableErrLDT_h__
#define __ERRLDT_EXTERN extern /*external declaration*/
#else //__DeclareGlobalVariableErrLDT_h__
#define __ERRLDT_EXTERN /*replace by nothing : we have to declare*/
#endif //__DeclareGlobalVariableErrLDT_h__
__ERRLDT_EXTERN CPA_EXPORT unsigned char g_ucLDTModuleId /*number of identification of the Erm module*/
#if defined(__DeclareGlobalVariableErrLDT_h__) && !defined(CPA_WANTS_IMPORT)
= C_ucModuleNotInitialized
#endif //__DeclareGlobalVariableErrLDT_h__&& CPA_WANTS_IMPORT
;
#ifdef __ERROR_STRINGS__
__ERRLDT_EXTERN CPA_EXPORT char * g_a_szLDTInformationModule []
#if defined(__DeclareGlobalVariableErrLDT_h__) && !defined(CPA_WANTS_IMPORT)
= {C_szLDTVersion, C_szLDTFullName, C_szLDTDate}
#endif /*__DeclareGlobalVariableErrLDT_h__ && CPA_WANTS_IMPORT*/
;
__ERRLDT_EXTERN CPA_EXPORT struct tdstErrorMsg_ g_a_stLDTTabErr [] /* Mandatory syntax 'g_a_st'+[Abbreviation of ModuleName]+'TabErr'*/
#if defined(__DeclareGlobalVariableErrLDT_h__) && !defined(CPA_WANTS_IMPORT)
= {0, NULL}; /*The Erm module need this variable even if it's equal to NULL*/
#endif //__DeclareGlobalVariableErrLgh_h__ && CPA_WANTS_IMPORT
;
#endif //__ERROR_STRINGS__
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif //__ERRLDT_H__

View File

@@ -0,0 +1,27 @@
/*------------------------------------------------------------------------------
FILE : Error.h
CREATED : 98/09/02
AUTHOR : Catalin Cocos
CONTENTS: LDT Error management
------------------------------------------------------------------------------*/
#ifndef __LDT_ERROR__
#define __LDT_ERROR__
#include "Link.h"
#define LDT_MAX_ERROR_DESCRIPTION 4000 /* maximum number of characters for error description */
extern char LDT_ErrDesc[LDT_MAX_ERROR_DESCRIPTION +1];
void SignalError(int level, LDT_tdst_Link * pLink, int errorcode, char* szErrDesc, char* szSourceFile, int line);
void InitErrFile();
void CLoseErrFile();
#ifdef LDT_ERROR_TREATMENT
#define ERRoR(level, link, code, Desc) SignalError(level, link, code, Desc, __FILE__, __LINE__)
#else
#define ERRoR(level, link, code, Desc)
#endif
#endif

View File

@@ -0,0 +1,42 @@
/*
**************************************************************************************************
* CPA_Ed_1 team *
* File Management *
**************************************************************************************************
*/
#ifndef __LDT_FILE_H__
#define __LDT_FILE_H__
#ifdef LDT_USE_SINGLE_FILE_BUFFER
extern char* GBuff;
extern unsigned long GBuffSize;
#endif
/* struct like a FILE , but for file in memory*/
typedef struct LDT_tdst_MemFile_ LDT_tdst_MemFile;
struct LDT_tdst_MemFile_ {
char *pName; /* Name of the file */
char *pBuffer; /* Pointer of the file in memory */
unsigned long Pos; /* Current Pos of the file in memory*/
size_t Size; /* Size of the file in memory*/
int sPathLength; /* Length of additional path */
};
/* methods */
long f_OpenMem(LDT_tdst_MemFile **_pInfoMemFile,char* _Name);
long f_CloseMem(LDT_tdst_MemFile *_pInfoMemFile);
long f_TellMem(LDT_tdst_MemFile *_pInfoMemFile );
long f_SeekMem(LDT_tdst_MemFile *_pInfoMemFile ,long _Offset,int _Origin);
long f_ReadMem(char * _PointerDest,size_t _Size,LDT_tdst_MemFile *_pInfoMemFile ) ;
#endif /*__LDT_FILE_H__*/

View File

@@ -0,0 +1,74 @@
/*------------------------------------------------------------------------------
FILE : Hash.h
CREATED : 98/05/12
AUTHOR : Catalin Cocos
CONTENTS: variable size hash table
------------------------------------------------------------------------------*/
#ifndef __LDT_HASH__
#define __LDT_HASH__
#include "DynArray.h"
/*
* To export code.
*/
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
/*------------------------------------------------------------------------------
TYPES
------------------------------------------------------------------------------*/
typedef struct LDT_tdst_DSHash_ LDT_tdst_DSHash;
struct LDT_tdst_DSHash_
{
int (* pfnDispersion ) (void*); /* the dispersion function */
void (* pfnDelete ) (void*); /* the element deletion function */
LDT_tdst_DSArray* pData; /* the vector */
};
/*------------------------------------------------------------------------------
FUNCTIONS
------------------------------------------------------------------------------*/
/*creation, initialization, deletion
--------------------------------------*/
CPA_EXPORT LDT_tdst_DSHash* LDT_DSHs_new(int (* _pfnDispersion ) (void*),
int (* _pfnCompare) (const void**, const void** ),
void (* _pfnDelete) (void*) ); /* creates a new hash */
CPA_EXPORT int LDT_DSHs_Init(LDT_tdst_DSHash*,
int (* _pfnDispersion ) (void*),
int (* _pfnCompare)(const void**, const void** ),
void (* _pfnDelete) (void*) ); /* initializes an existing hash */
CPA_EXPORT void LDT_DSHs_delete( LDT_tdst_DSHash*, int ); /* deletes an existing array*/
CPA_EXPORT void LDT_DSHs_SetGranularity( LDT_tdst_DSHash*, int); /* sets the dynamic aray elements granularity */
/* Clean up
-------------*/
CPA_EXPORT void LDT_DSHs_FreeExtra( LDT_tdst_DSHash* ); /* frees the unused memory */
CPA_EXPORT void LDT_DSHs_RemoveAll( LDT_tdst_DSHash*, int ); /* removes all elements */
CPA_EXPORT void LDT_DSHs_Close( LDT_tdst_DSHash*, int ); /* clears the hash memory */
/* Accessing elements
-----------------------*/
CPA_EXPORT void* LDT_DSHs_GetEqOf( LDT_tdst_DSHash*, void* ); /* gets the hash element matching the parameter*/
CPA_EXPORT void* LDT_DSHs_RemoveEqOf( LDT_tdst_DSHash*, void* ); /* removes the hash element matching the parameter*/
CPA_EXPORT void* LDT_DSHs_Insert( LDT_tdst_DSHash*, void*, int ); /* inserts the element in the hash table*/
#endif

View File

@@ -0,0 +1,228 @@
/*------------------------------------------------------------------------------
FILE : Interface.h
CREATED : 98/05/21
AUTHOR : Catalin Cocos
CONTENTS: user end functions
------------------------------------------------------------------------------*/
#ifndef __LDT_INTERFACE__
#define __LDT_INTERFACE__
#include "hash.h" /* to export the dynamic array and the hash */
/*
* To export code.
*/
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
/* Constants
--------------*/
#define LDT_REG_SECTION 0 /* registers section callbacks */
#define LDT_REG_FILE 1 /* registers file callbacks */
/* Types */
/* result of parsing a line */
typedef enum eParseResult_
{
ParseResult_EOF,
ParseResult_Directive,
ParseResult_BeginSection,
ParseResult_EndSection,
ParseResult_Entry,
ParseResult_Error
} LDT_tdeParseResult;
typedef void * HREF;
/*
________________________________________________________________________________________________
Exported structures
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/* link flags */
#define LDT_LF_ALLOCATED 0x00010000
#define LDT_LF_LOADED 0x00020000
#define LDT_LF_ALLFILE 0x00040000
#define LDT_LF_FILE 0x00080000
#define LDT_LF_VOLATILE 0x00100000
/* the callback registration */
typedef struct LDT_tdst_CallbackEntry_ LDT_tdst_CallbackEntry;
/* the section link */
typedef struct LDT_tdst_Link_ LDT_tdst_Link;
struct LDT_tdst_CallbackEntry_
{
char* szType; /* the section type */
int (*Create) ( LDT_tdst_Link* ); /* the creation function */
int ( *Load ) ( LDT_tdst_Link* ); /* the loading function */
};
#pragma pack ( push, default_packing )
#pragma pack ( 1 )
struct LDT_tdst_Link_
{
char* szFile; /* the file containing the section - stored in a string table */
char* szParent; /* the section parent */
char* szName; /* the section name */
LDT_tdst_CallbackEntry* Type;
unsigned long dwFlags; /* flags */
void* pObject; /* the allocated memory structure or NULL */
LDT_tdst_Link* pParent; /* the section that requested the loading */
unsigned short wUnsolvedRefs; /* number of references to postprocess */
};
#pragma pack ( pop, default_packing )
/*
________________________________________________________________________________________________
Exported methods
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/* Initialization/Closing functions
-------------------------------------*/
CPA_EXPORT int LDT_Initialize();
CPA_EXPORT int LDT_Close();
CPA_EXPORT void LDT_CleanUpRegistrations();
/* Linking persistence management functions
------------------------------------------*/
CPA_EXPORT void LDT_SetLinkingPersistence (unsigned short Level);
CPA_EXPORT void LDT_Forget(unsigned short Level);
/* Reference solving function
-------------------------------------*/
CPA_EXPORT int LDT_Flush();
CPA_EXPORT int LDT_FlushAndForget(unsigned short Level);
/* Loading functions
-------------------------------------*/
CPA_EXPORT void* LDT_LoadSection( char* );
CPA_EXPORT void* LDT_LoadSectionAt( char*, void* );
CPA_EXPORT LDT_tdst_Link* LDT_GetLink( char *szSection );
/* In-callback link manipulation functions
-------------------------------------*/
CPA_EXPORT void LDT_SetVolatileSubsection( LDT_tdst_Link* );
/* In-callback parsing functions
-------------------------------------*/
CPA_EXPORT void LDT_SkipSection();
CPA_EXPORT char *LDT_szGetParam( int i );
CPA_EXPORT LDT_tdeParseResult LDT_GetNextEntry();
CPA_EXPORT char *LDT_szGetSectionName();
CPA_EXPORT char *LDT_szGetSectionType();
CPA_EXPORT char *LDT_szGetEntryName();
CPA_EXPORT int LDT_iGetNbParams();
CPA_EXPORT void LDT_SplitSectionName( char *szSection, char *szFile, char *szParent, char *szType, char *szId );
CPA_EXPORT int LDT_ComputeSectionName( LDT_tdst_Link *, char * );
/* reference delaying methods */
CPA_EXPORT HREF LDT_CreateRefsTable( );
CPA_EXPORT void LDT_AddToRefsTable( HREF hRef, LDT_tdst_Link *pObj, int iType, short xCount, ... );
CPA_EXPORT int LDT_GetRefFromTable( HREF hRef, LDT_tdst_Link **pObj, LDT_tdst_Link **pGetFrom, int *iType, short *xCount, long **pVal );
CPA_EXPORT void LDT_FreeRefValues( long *p );
CPA_EXPORT HREF LDT_RegisterSolver( void(* Solve)(HREF), int iPri );
/* File values methods */
CPA_EXPORT unsigned long LDT_GetFileLong( int i );
CPA_EXPORT double LDT_GetFileDouble( int i );
CPA_EXPORT void LDT_SetFileLong( int i, unsigned long ul );
CPA_EXPORT void LDT_SetFileDouble( int i, double d );
CPA_EXPORT unsigned long LDT_GetTempLong( int i );
CPA_EXPORT void LDT_SetTempLong( int i, unsigned long ul );
/* Default Callbacks
-----------------------*/
CPA_EXPORT int LDT_Default_NULL_Create( LDT_tdst_Link* );
CPA_EXPORT int LDT_Default_Load( LDT_tdst_Link* );
/* Type Registration functions
---------------------------------*/
CPA_EXPORT int LDT_RegisterType( char* szType, int (*) ( LDT_tdst_Link* ), int (*) ( LDT_tdst_Link* ), int);
CPA_EXPORT LDT_tdst_CallbackEntry* LDT_IsTypeRegistered( char* szType, int );
CPA_EXPORT int LDT_UnregisterType( char* szType, int );
/* Path Registration functions
---------------------------------*/
CPA_EXPORT int LDT_AddBaseDirectory( char* szBasePath );
CPA_EXPORT int LDT_RegisterPath( char* szPath, char* szFileTypes );
/* CPA_EXPORT void LDT_DeletePath( char* szPath ); */
/* CPA_EXPORT void LDT_EraseRegisteredPaths(); */
/* File finding function
---------------------------------*/
CPA_EXPORT int LDT_SearchFile( char* szFile, char* Buffer );
/* Link-Value association functions
---------------------------------*/
CPA_EXPORT void LDT_SetLinkValue( LDT_tdst_Link*, unsigned long );
CPA_EXPORT unsigned long LDT_GetLinkValue( LDT_tdst_Link* );
CPA_EXPORT unsigned long LDT_RemoveLinkValue( LDT_tdst_Link* pLink );
/* Access to the referenced files history list
I HATE to do this, but it sewems that the material editor is in desperate need of such a list.
------------------------------------------------------------------------------------------------*/
CPA_EXPORT int LDT_GetReferencedFilesNumber();
CPA_EXPORT const char* LDT_GetReferencedFile(int idx);
/*
________________________________________________________________________________________________
Exported macros
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
/* In-callback memory allocation/deallocation macros
------------------------------------------------------*/
#ifdef LDT_USE_MMG
#include "Mem.h"
#define LDT_M_malloc LDT_malloc_Mmg
#define LDT_M_free LDT_free_Mmg
#define LDT_M_realloc LDT_realloc_Mmg
#else
#define LDT_M_malloc malloc
#define LDT_M_free free
#define LDT_M_realloc realloc
#endif /* LDT_USE_MMG */
#endif

View File

@@ -0,0 +1,120 @@
/*------------------------------------------------------------------------------
FILE : Link.h
CREATED : 98/05/19
AUTHOR : Catalin Cocos
CONTENTS: linktable/position structures & functions
------------------------------------------------------------------------------*/
#ifndef __LDT_LINK__
#define __LDT_LINK__
#include "Hash.h"
#include "Interface.h"
#include "File.h"
/* Structures
----------------*/
/* section position inside the containing file */
typedef struct LDT_tdst_Position_ LDT_tdst_Position;
struct LDT_tdst_Position_
{
char* szName; /* the section name */
char* szParent; /* the section parent */
LDT_tdst_CallbackEntry* Type; /* the type of the section */
unsigned short uwFlags; /* flags */
unsigned long dwPos; /* the offset inside the file */
unsigned long nLine; /* the text line */
int iLevel; /*the level in file*/
};
/* Reference Collection for a File */
typedef struct LDT_tdst_Refs_ LDT_tdst_Refs;
struct LDT_tdst_Refs_
{
char* szFile; /* the file */
LDT_tdst_DSArray Links; /* the references */
LDT_tdst_Refs* p_NextReferencedFile;/* the next file */
#ifdef LDT_MULTITHREADED
LDT_tdst_MemFile* pFile; /* the opened file */
#endif
};
/* Link associated value */
typedef struct LDT_tdst_LinkValue_ LDT_tdst_LinkValue;
struct LDT_tdst_LinkValue_
{
LDT_tdst_Link* pLink;
unsigned long value;
};
/* Globals
-------------*/
extern LDT_tdst_DSHash g_HashLinks; /* the linktable */
extern LDT_tdst_DSArray g_ArRefs; /* thereferences, grouped by file */
extern LDT_tdst_DSArray g_ArFilenames; /* thefilename strings */
extern char LDT_EMPTY_STR[1];
extern LDT_tdst_Refs* g_pFileToProcess; /* the file to load */
extern LDT_tdst_Refs* g_pLastFileQueued; /* the last fiel referenced */
#ifdef LDT_MULTITHREADED
extern LDT_tdst_Refs* g_pFileToRead; /* the file to read */
#endif
/* Functions
--------------*/
/* Link - related */
int LDT_Link_Dispersion( LDT_tdst_Link*);
int LDT_Compare_Links(const void**, const void** );
int LDT_Compare_LinkValues(const void**, const void** );
LDT_tdst_Link* LDT_CreateLinkFromReference( char* szSection );
LDT_tdst_Link* LDT_Create_Link( char* szName, /* the section name */
char* szParent, /* the section parent */
char* szFile, /* the file containing the section - stored in a string table */
LDT_tdst_CallbackEntry* Type,
unsigned long dwFlags, /* flags */
void* pObject, /* the allocated memory structure or NULL */
LDT_tdst_Link* pParent); /* the section that requested the loading */
void LDT_Delete_Link( LDT_tdst_Link *);
/* Position - related */
int LDT_Compare_Positions(const void**, const void** );
LDT_tdst_Position *LDT_Create_Position( char *szName,
char *szParent,
LDT_tdst_CallbackEntry* Type,
unsigned short uwFlags,
unsigned long ulPos,
unsigned long nLine,
int iLevel );
void LDT_Delete_Position( LDT_tdst_Position *pos );
/* String - related */
int LDT_Compare_Strings(const void**, const void** );
/* Reference - related */
void AddReference( LDT_tdst_Link* );
int LDT_Compare_Refs(const void**, const void** );
#endif

View File

@@ -0,0 +1,35 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* LDT_Mem.h
* CPA_Ed_1 team
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
*/
#ifndef __LDT_MEM__
#define __LDT_MEM__
/*
* To export code.
*/
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
CPA_EXPORT void* LDT_malloc_Mmg(size_t _size);
CPA_EXPORT void* LDT_realloc_Mmg(void * _PointerSrc, size_t _Size);
CPA_EXPORT void LDT_free_Mmg(void *_Pointer);
void LDT_fn_v_Mem_InitModule(void);
void LDT_fn_v_Mem_CloseModule(void);
void LDT_fn_v_Mem_InitWithMemLevel(unsigned long *);
#endif /* __LDT_MEM__ */

View File

@@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////
//
// Memory Management of the Module : LDT
//
// File Name : MmgLDT.h
// Date :
// Author : CPA_Ed_1 team
//
/////////////////////////////////////////////////////////////
#ifndef __MmgLDT_H__
#define __MmgLDT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLLs who are using this module : */
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#include "MMG.h"
typedef enum e_ucLDTStaticBlocks_
{
E_ucLDTMemoryBlock0 = 0,
E_ucLDTMemoryBlock1 = 1,
E_ucLDTMemoryBlock2 = 2,
E_ucLDTMemoryBlock3 = 3,
E_ucLDTMemoryBlock4 = 4,
E_ucLDTMemoryBlock5 = 5,
E_ucLDTMemoryBlock6 = 6,
E_ucLDTMemoryBlock7 = 7,
E_ucLDTMemoryBlock8 = 8,
E_ucLDTMaxBlocksNb // maximum number of static block, You have to follow this syntax 'E_uc+ Abbreviation Module +MaxBlocksNb'
} e_ucLDTStaticBlocks;
#undef EXTERN
#ifdef __DeclareGlobalVariableMmgLDT_h__
#define EXTERN /*nothing*/
#else // no __DeclareGlobalVariableMmgLDT_h__
#define EXTERN extern
#endif //__DeclareGlobalVariableMmgLDT_h__
EXTERN CPA_EXPORT struct tdstBlockInfo_ g_a_stLDTBlocksInfo[E_ucLDTMaxBlocksNb];
#ifdef __DYNAMIC_MALLOC_ALLOWED__
#ifdef __DEBUG_MALLOC_MODE__
EXTERN CPA_EXPORT struct tdstDynInfo_ g_stLDTDynInfo;
#endif //__DEBUG_MALLOC_MODE__
#endif //__DYNAMIC_MALLOC_ALLOWED__
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif //__MmgLDT_H__

View File

@@ -0,0 +1,91 @@
/*------------------------------------------------------------------------------
FILE : Parser.c
CREATED : 98/05/17
AUTHOR : Mircea Petrescu
CONTENTS: parsing structures, variables & functions
------------------------------------------------------------------------------*/
#ifndef __LDT_PARSER_H
#define __LDT_PARSER_H
#include "File.h"
#include "DynArray.h"
#include "Link.h"
extern char g_szType[512];
extern char g_szName[512];
extern char g_szParent[512];
extern char g_szId[512];
extern LDT_tdst_Link* g_CrtSection;
#ifdef LDT_MULTITHREADED
extern CRITICAL_SECTION GReadExclusion;
extern HANDLE GReadCount;
extern HANDLE GReadLimit;
extern HANDLE GFileLimit;
#define LDT_READ_COUNT "LDT_Rd_S"
#define LDT_READ_LIMIT "LDT_Rd_L"
#define MAX_FILE_NO 6
#endif
/* Constants */
/* directive flags */
#define LDT_uw_Anl_Normal 0x0000 /* Normal analyse */
#define LDT_uw_Anl_Comments 0x0001 /* It's a comment, don't care */
#define LDT_uw_Anl_ForceAnalyse 0x0002 /* To force analyse of section */
#define LDT_uw_Anl_NotSaveSection 0x0004 /* To not save section in memory */
#define LDT_uw_Anl_WarnIfNotHere 0x0008 /* No error if section does not exist */
/* Types */
/* a file encapsulation for parsing */
typedef struct LDT_tdst_FileDesc_ LDT_tdst_FileDesc;
struct LDT_tdst_FileDesc_
{
LDT_tdst_MemFile* _pInfoMemFile; /* the file handle */
char* szFile; /* the file name */
LDT_tdst_DSArray arContents; /* the file parsed contents */
int iLevel; /* the (sub)section level */
int iLineNumber; /* the current line */
int iLastIndex; /* for parsing purposes */
char chLastChar; /* same */
short sLengthDiff; /* length of additional path */
unsigned short uwFlags; /* various directive flags */
unsigned long ulValues[64]; /* file long values */
double dValues[8]; /* file double values */
unsigned short uwLoadType;
};
extern LDT_tdst_FileDesc* g_FileDesc;
extern LDT_tdst_Link *pParent[100];
extern LDT_tdst_FileDesc TheFileDesc;
/* Functions */
LDT_tdeParseResult fn_e_ParseLine(int bSeek );
LDT_tdeParseResult LDT_GetNextEntry( );
int Solve( LDT_tdst_Refs *refs );
void InitParser( void );
//void LDT_SkipSection( );
LDT_tdst_MemFile* AccessFile( char* szFile );
#endif

View File

@@ -0,0 +1,41 @@
/*------------------------------------------------------------------------------
FILE : DynArray.h
CREATED : 98/06/11
AUTHOR : Mircea Petrescu
CONTENTS: management of unsolved references
( for get x from reference operations )
------------------------------------------------------------------------------*/
#ifndef __LDT_Refs__
#define __LDT_Refs__
/* Types */
typedef struct tdst_Ref_ tdst_Ref;
/* the packing of a reference */
struct tdst_Ref_
{
LDT_tdst_Link *pObject;
LDT_tdst_Link *pGetFrom;
int iType;
short xCount;
long *pVal;
};
/* handle to a reference list */
typedef void * HREF;
typedef struct tdst_Solver_ tdst_Solver;
struct tdst_Solver_
{
void (*Solve)( HREF );
HREF hRef;
int iPriority;
};
int SortSolvers( const void **A, const void **B );
#endif

View File

@@ -0,0 +1,38 @@
/*------------------------------------------------------------------------------
FILE : Register.h
CREATED : 19/05/97
AUTHOR : Catalin Cocos
CONTENTS: callback registering structures & functions
------------------------------------------------------------------------------*/
#ifndef __LDT_REGISTER__
#define __LDT_REGISTER__
#include "Link.h"
#include "Parser.h"
#include "DynArray.h"
/* Constants
--------------*/
#define LDT_REG_SECTION 0 /* registers section callbacks */
#define LDT_REG_FILE 1 /* registers file callbacks */
/* Globals
-------------*/
extern tdst_DSArray g_ArSectionCallbacks; /* the section callbacks */
extern tdst_DSArray g_ArFileCallbacks; /* the file callbacks */
/* Functions
-------------*/
int LDT_Compare_CallbackEntries(const void**, const void** );
LDT_tdst_CallbackEntry* GetType( char* szType, int Mode);
#endif

View File

@@ -0,0 +1,52 @@
/*------------------------------------------------------------------------------
FILE : Register.h
CREATED : 98/05/19
AUTHOR : Catalin Cocos
CONTENTS: callback registering structures & functions
------------------------------------------------------------------------------*/
#ifndef __LDT_REGISTER__
#define __LDT_REGISTER__
#include "Link.h"
#include "Parser.h"
#include "DynArray.h"
/* Constants
--------------*/
#define LDT_REG_SECTION 0 /* registers section callbacks */
#define LDT_REG_FILE 1 /* registers file callbacks */
/* Globals
-------------*/
extern LDT_tdst_DSArray g_ArSectionCallbacks; /* the section callbacks */
extern LDT_tdst_DSArray g_ArFileCallbacks; /* the file callbacks */
extern LDT_tdst_DSArray g_ArSolvers; /* the post-process solvers */
extern LDT_tdst_DSArray g_ArPaths; /* the paths */
extern LDT_tdst_DSArray g_ArPathStrings; /* the path strings */
extern LDT_tdst_DSArray g_ArBaseDirectories; /* the base paths */
/* Functions
-------------*/
int LDT_Compare_CallbackEntries(const void**, const void** );
LDT_tdst_CallbackEntry* GetType( char* szType, int Mode);
/* Types
----------*/
typedef struct LDT_tdst_TypePaths_ LDT_tdst_TypePaths;
struct LDT_tdst_TypePaths_
{
char* szExtension;
LDT_tdst_DSArray arPaths;
};
#endif

View File

@@ -0,0 +1,230 @@
/*------------------------------------------------------------------------------
FILE : StdInc.h
CREATED : 98/05/11
AUTHOR : Catalin Cocos
CONTENTS: standard includes - header to precompile
------------------------------------------------------------------------------*/
#ifndef __LDT_STDINC__
#define __LDT_STDINC__
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/* PROJECT-CONFIGURING DEFINES */
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/*=============================COMPATIBILITY==================================*/
#define LDT_SCR /* define this to enable LDT/SCR interfacing facilities */
/*=================================DISK=======================================*/
#define LDT_MULTITHREADED
/* define this if you want to use LDT in a multithreading environment */
#define LDT_USE_SINGLE_FILE_BUFFER /* WORKS ONLY IN THE SINGLETHREADED MODE */
/* define this if you want to use a persistent and unique file buffer */
/*=============================PERFORMANCE====================================*/
#define LDT_LOG_STATISTICS
/* define this if you want LDT to print an information log file at the
end of the execution */
#define LDT_LOG_MEMORY /* WORKS ONLY IN THE SINGLETHREADED MODE */
/* define this if you want LDT to generate memory usage information */
/*================================ERRoR=======================================*/
#define LDT_LOG_ERRORS /* log warnings/errors */
#define LDT_DISPLAY_ERRORS /* display error messages */
//#define LDT_DISPLAY_WARNINGS /* display warning messages */
#define LDT_WARNING_LEVEL 3 /* the warning level:
0 - no warnings (DEFAULT)
1 - level 1 warnings
2 - level 2 & 1 warnings
3 - levels 1, 2 & 3
4 - all warnings */
#define LDT_ERROR_LEVEL 0 /* the error level:
0 - errors only for level 0 (DEFAULT)
1 - level 1 warnings are treated as errors
2 - level 2 & 1 warnings are treated as errors
3 - level 1, 2 & 3 are treated as errors
4 - all warnings are treated as errors */
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/* DO NOT EDIT THE FILE BEYOND THIS POINT ! */
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
#ifdef U64
#undef LDT_MULTITHREADED
#undef LDT_LOG_STATISTICS
#undef LDT_LOG_MEMORY
#endif
#ifdef LDT_DISPLAY_WARNINGS
#define LDT_DISPLAY_ERRORS
#endif
#ifdef LDT_LOG_ERRORS
#define LDT_ERROR_TREATMENT
#endif
#ifdef LDT_DISPLAY_ERRORS
#define LDT_ERROR_TREATMENT
#endif
#ifdef LDT_MULTITHREADED
#undef LDT_USE_SINGLE_FILE_BUFFER
#undef LDT_LOG_MEMORY
#define LDT_USE_WIN
#endif
#ifdef LDT_LOG_MEMORY
#define LDT_LOG_STATISTICS
#endif
#ifdef LDT_LOG_STATISTICS
#define LDT_USE_WIN
#endif
#ifdef LDT_USE_WIN
#pragma warning(disable: 4115)
#pragma warning(disable: 4201)
#pragma warning(disable: 4214)
#include <windows.h>
#include <process.h>
#include <limits.h>
#include <time.h>
#else
//typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
#endif
#ifdef LDT_LOG_STATISTICS
/* Log/stat stuff
-------------------*/
extern unsigned TimerStartCount;
extern unsigned TimerStopCount;
extern LONGLONG Frequency;
extern LONGLONG TimingOverhead;
extern LONGLONG StartOverhead;
extern LONGLONG StopOverhead;
typedef struct TimerStruct_ TimerStruct;
struct TimerStruct_
{
LONGLONG TimeCounter;
LONGLONG LastValue;
unsigned LastStartCount;
unsigned LastStopCount;
};
void InitializeTimingEnvironment();
void InitTimer(TimerStruct*);
void StartTimer(TimerStruct*);
void StopTimer(TimerStruct*);
double ReadTimer(TimerStruct*);
#endif
/*------------------------------------------------------------------------------
COMPILER-DEPENDENT DEFINES
------------------------------------------------------------------------------*/
#ifdef __WATCOMC__
#define __inline
#endif /* __WATCOMC__ */
#ifdef _MSC_VER /* Visulal C/C++ compiler */
#pragma warning(disable: 4514) /* Warning: unreferenced inline/local function has been removed */
#endif /* _MSC_VER */
/*------------------------------------------------------------------------------
STANDARD INCLUDES
------------------------------------------------------------------------------*/
#ifdef U64
#define LDT_USE_MMG /* on ultra 64, use the memory manager*/
#include <ultra.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <search.h>
#include <assert.h>
#include <string.h>
#include <io.h>
#endif /* U64 */
/*------------------------------------------------------------------------------
MEMORY ALLOCATION TYPE
------------------------------------------------------------------------------*/
#ifdef LDT_USE_MMG
#define malloc LDT_malloc_Mmg
#define realloc LDT_realloc_Mmg
#define free LDT_free_Mmg
#include "Mem.h"
#endif /* LDT_USE_MMG */
/*------------------------------------------------------------------------------
DEFINES
------------------------------------------------------------------------------*/
/* Code exportation */
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
#ifdef LDT_LOG_MEMORY
#include <malloc.h>
extern unsigned long g_allocsize;
extern unsigned long g_Maxallocsize;
extern unsigned long g_size;
extern void* g_palloc;
extern unsigned long g_allocCount;
extern unsigned long g_reallocCount;
extern unsigned long g_freeCount;
#define malloc(x) ( g_size = x, g_allocsize += g_size, g_allocCount++, g_Maxallocsize = max(g_Maxallocsize, g_allocsize), malloc(g_size))
#define realloc( y, x) (g_palloc = y, g_size = x, g_reallocCount++, g_allocsize += g_size - (g_palloc?_msize(g_palloc):0), g_Maxallocsize = max(g_Maxallocsize, g_allocsize), realloc( g_palloc, g_size ))
#define free( y ) (g_palloc = y, g_freeCount++, g_size =(g_palloc?_msize(g_palloc):0), g_allocsize -= g_size, free(g_palloc))
#endif
#endif /* __LDT_STDINC__ */

View File

@@ -0,0 +1,67 @@
/*
**************************************************************************************************
* CPA_Ed_1 team *
* general types *
**************************************************************************************************
*/
#ifndef __LDT_TYPE_H__
#define __LDT_TYPE_H__
#include "StdInc.h"
/*---------------------------------------------------------
Define for types
-----------------------------------------------------------*/
/*---------------------------------------------------------
Define for error types
-----------------------------------------------------------*/
/*
* Enum that describes the list of all errors Id.
*/
typedef enum LDT_tde_Err_Identification_
{
LDT_EI_Err_InvalidAddress = 0xffffffff,
LDT_EI_Err_None = 0,
LDT_EI_Err_Malloc,
LDT_EI_Err_OpenFile,
LDT_EI_Err_OpenWrite,
LDT_EI_Err_CloseFile,
LDT_EI_Err_ReadFile,
LDT_EI_Err_SeekFile,
LDT_EI_Err_MemMove,
LDT_EI_Err_NotEnoughDataForMove,
LDT_EI_Err_AllreadyClose,
LDT_EI_Err_SeekInMem,
LDT_EI_Err_NotEnoughPlaceForWrite,
LDT_EI_Err_EndOfFile,
LDT_EI_Err_AtemptTOWriteInReadFile,
LDT_EI_Err_DuplicateRegister,
LDT_EI_Err_RegisterWorkspaceNULL,
LDT_EI_Err_NotRegistered,
LDT_EI_Err_AddressConflict,
LDT_EI_Err_InexistentLink
} LDT_tde_Err_Identification;
typedef enum LDT_D_tType_
{
ReadType,
WriteType
} LDT_D_tType;
/*---------------------------------------------------------
Define for types
-----------------------------------------------------------*/
#endif /*__LDT_TYPE_H__*/