229 lines
6.8 KiB
C
229 lines
6.8 KiB
C
/*------------------------------------------------------------------------------
|
|
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
|
|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
|
/* 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
|
|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
|
|
|
|
|
/* 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
|
|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
|
*/
|
|
|
|
/* 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
|
|
|