/* *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * SCR_Anl.h * Scripts, Beaudet Christophe *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * */ #ifndef __SCR_Anl_h__Types #define __SCR_Anl_h__Types #ifndef __Only_Types__ #define __SCR_Anl_h__Undef #define __Only_Types__ #endif /* !__Only_Types__ */ /* *================================================================================================= * Includes. *================================================================================================= */ #include "SCR_Cfg.h" #include "SCR_Cxt.h" #include "SCR_DyAr.h" #include "SCR_File.h" #include "SCR_Sect.h" #ifdef __SCR_Anl_h__Undef #undef __Only_Types__ #undef __SCR_Anl_h__Undef #endif /* __SCR_Anl_h__Undef */ /* *================================================================================================= * Constants. *================================================================================================= */ /* * 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 */ /* * To describe dynamic flags. */ #define SCR_CDF_uw_Anl_Normal 0x0000 /* Normal analyse */ #define SCR_CDF_c_Anl_Normal 'n' /* For automatic references */ #define SCR_CDF_uw_Anl_Comments 0x0001 /* It's a comment, don't care */ #define SCR_CDF_uw_Anl_ForceAnalyse 0x0002 /* To force analyse of section */ #define SCR_CDF_c_Anl_ForceAnalyse 'f' /* For automatic references */ #define SCR_CDF_uw_Anl_NotSaveSection 0x0004 /* To not save section in memory */ #define SCR_CDF_uw_Anl_WarnIfNotHere 0x0008 /* No error if section does not exist */ /* *================================================================================================= * Types. *================================================================================================= */ /* * Return value for callbacks. */ typedef enum SCR_tde_Anl_ReturnValue_ { SCR_ERV_Anl_NormalReturn = 0, SCR_ERV_Anl_TerminateCurrentSection, SCR_ERV_Anl_TerminateParentSection, SCR_ERV_Anl_TerminateMainSection, SCR_ERV_Anl_TerminateFile, } SCR_tde_Anl_ReturnValue; /* * Value for callback action. */ typedef enum SCR_tde_Anl_Action_ { SCR_EA_Anl_Invalid = 0, SCR_EA_Anl_BeginSection, SCR_EA_Anl_Entry, SCR_EA_Anl_BeginSubSection, SCR_EA_Anl_EndSubSection, SCR_EA_Anl_EndSection, SCR_EA_Anl_AlreadyAnalysed, } SCR_tde_Anl_Action; /* * A user callback for parser. */ typedef SCR_tde_Anl_ReturnValue (* SCR_tdpfn_Anl_Callback)(SCR_tdst_File_Description *, char *, char *[], SCR_tde_Anl_Action); /* * A structure to describe a saved callback. */ typedef struct SCR_tdst_Anl_Callback_ { SCR_tdst_DyAr_Header stHeader; /* Header of element */ char a_szSectionName[SCR_CV_ui_Cfg_MaxLenAtomicName]; /* Action part of name */ SCR_tdpfn_Anl_Callback pfn_eCallback; /* Address of function */ char cForSection; /* Call back for a section */ } SCR_tdst_Anl_Callback; /* * Structure that describe a section in a file. */ typedef struct SCR_tdst_Anl_SectionDes_ { SCR_tdst_DyAr_Header stHeader; /* Header of element */ SCR_tdst_Cxt_DynBuffers stBuffers; /* Buffers to describe section title */ SCR_tdst_Cxt_Position stBeginPosition; /* Position of section in file */ SCR_tdst_Cxt_Position stEndPosition; /* Position of section in file */ unsigned short uwDynamicFlags; /* Flags of section */ struct SCR_tdst_Anl_SectionDes_ *p_stParentSection; /* Parent section description */ unsigned int uiIndexOfHashValue; /* Index in hash table of that section */ SCR_tdst_Sect_Open *p_stOpenSection; /* Address of open section */ } SCR_tdst_Anl_SectionDes; /* * For the parser. */ typedef struct SCR_tdst_Anl_ParserValues_ { SCR_tdst_Cxt_Description *p_stContext; SCR_tdst_Anl_Callback *p_stCallback; SCR_tde_Anl_ReturnValue eReturnValue; } SCR_tdst_Anl_ParserValues; #endif /* !__SCR_Anl_h__Types */ /* *================================================================================================= * Global variables. *================================================================================================= */ CPA_EXPORT extern SCR_tdst_DyAr_Description SCR_g_st_Anl_ArrayCallbacks; extern int g_iExitBeforeLevel; /* *================================================================================================= * Macros. *================================================================================================= */ #if !defined(__SCR_Anl_h__Macros) && !defined(__Only_Types__) #define __SCR_Anl_h__Macros /* * Place the current context and the current file to a given position. */ #define SCR_M_Anl_CxtFileToPos(_Context, _Pos)\ {\ memcpy(&((_Context)->stPosition), &(_Pos), sizeof(SCR_tdst_Cxt_Position));\ SCR_M_File_Seek(&(_Context)->p_stOpenFile->stFile, (_Context)->stPosition.lAfterSeekInFile, SEEK_SET);\ } #endif /* __SCR_Anl_h__Macros */ /* *================================================================================================= * Protos. *================================================================================================= */ #if !defined(__SCR_Anl_h__Protos) && !defined(__Only_Types__) #define __SCR_Anl_h__Protos extern void fn_v_Anl_InitModule(void); extern void fn_v_Anl_CloseModule(void); extern SCR_tdst_Anl_Callback *fnp_st_Anl_AddCallback(char *, SCR_tdpfn_Anl_Callback, char); extern void fn_v_Anl_DeleteCallback(SCR_tdst_Anl_Callback *); extern SCR_tdst_Anl_Callback *fnp_st_Anl_SearchCallback(char *, char); extern SCR_tdst_Anl_SectionDes *fnp_st_Anl_AddSectionDes(SCR_tdst_Cxt_Description *, SCR_tdst_Anl_SectionDes *); extern SCR_tdst_Anl_SectionDes *fnp_st_Anl_SearchSectionDes(SCR_tdst_File_Open *, char *, unsigned int, unsigned int); extern SCR_tdst_Anl_SectionDes *fnp_st_Anl_ComputeCompleteName(SCR_tdst_Cxt_Description *, char); extern void fn_v_Anl_ComputeSeekEnd(SCR_tdst_Cxt_Description *); extern void fn_v_Anl_UpdateInfos(SCR_tdst_Cxt_Description *); extern int fn_i_Anl_LineToContext(SCR_tdst_Cxt_Description *); CPA_EXPORT extern void fn_v_Anl_ContextToSection(SCR_tdst_Cxt_Description *, char *); CPA_EXPORT extern void fn_v_Anl_ContextToEndSection(SCR_tdst_Cxt_Description *); CPA_EXPORT extern void fn_v_Anl_ContextToFile(SCR_tdst_Cxt_Description *); extern char fn_c_Anl_CallToCallback(SCR_tdst_Anl_ParserValues *, SCR_tde_Anl_Action, int *); extern void fn_v_Anl_ParseCurrentSection(unsigned short); extern void fn_v_Anl_ReduceMemory(void); extern void fn_v_Anl_DeleteWithMemLevel(unsigned char, unsigned char); #endif /* !__SCR_Anl_h__Protos && !__Only_Types__ */