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,289 @@
# Microsoft Developer Studio Project File - Name="SCR" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=SCR - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Scr.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Scr.mak" CFG="SCR - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "SCR - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "SCR - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "SCR - Win32 Debug Protected" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/TempGrp/SCR", QEAAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
!IF "$(CFG)" == "SCR - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "x:\cpa\lib"
# PROP Intermediate_Dir "Tmp\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "X:\CPA\Public" /D "NDEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "SCR_DM_OptCFiles" /D "_AFXDLL" /YX /FD /c
# SUBTRACT CPP /Fr
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"X:\CPA\Lib\SCRP5_vr.lib"
!ELSEIF "$(CFG)" == "SCR - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "X:\CPA\Lib"
# PROP Intermediate_Dir "Tmp\SCRP5_vd"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "X:\CPA\Public" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "SCR_DM_OptCFiles" /D "_AFXDLL" /YX /FD /c
# SUBTRACT CPP /Fr
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"X:\CPA\Lib\SCRP5_vd.lib"
!ELSEIF "$(CFG)" == "SCR - Win32 Debug Protected"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug Protected"
# PROP BASE Intermediate_Dir "Debug Protected"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "x:\CPA\Lib"
# PROP Intermediate_Dir "Tmp\SCRP5_vp"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /I "X:\CPA\Public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "X:\CPA\Public" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "SCR_DM_OptCFiles" /D "SCR_DM_ProtectedVersion" /D "_AFXDLL" /YX /FD /c
# SUBTRACT CPP /Fr
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"X:\CPA\Lib\SCRP5_vd.lib"
# ADD LIB32 /nologo /out:"X:\CPA\Lib\SCRP5_vp.lib"
!ENDIF
# Begin Target
# Name "SCR - Win32 Release"
# Name "SCR - Win32 Debug"
# Name "SCR - Win32 Debug Protected"
# Begin Group "Source Files"
# PROP Default_Filter ".c"
# Begin Source File
SOURCE=.\SCR_Anl.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Bin.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Cxt.c
# End Source File
# Begin Source File
SOURCE=.\SCR_DyAr.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Err.c
# ADD CPP /W3
# End Source File
# Begin Source File
SOURCE=.\SCR_File.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Hash.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Link.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Mem.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Ntfy.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Page.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Pars.c
# End Source File
# Begin Source File
SOURCE=.\SCR_RdL0.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Sect.c
# End Source File
# Begin Source File
SOURCE=.\SCR_SvL0.c
# End Source File
# Begin Source File
SOURCE=.\SCR_SvL1.c
# End Source File
# Begin Source File
SOURCE=.\SCR_Vars.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\public\SCR\ErrScr.h
# End Source File
# Begin Source File
SOURCE=..\..\public\SCR\MmgScr.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Anl.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Cfg.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_CFil.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Cxt.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Dbg.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_DyAr.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Err.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_File.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Hash.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Link.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Mem.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Ntfy.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Page.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Pars.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_RdL0.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Sect.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_SvL0.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_SvL1.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_Vars.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\SCR_XXXX.h
# End Source File
# End Group
# Begin Group "Others"
# PROP Default_Filter "txt"
# Begin Source File
SOURCE=..\..\Public\SCR\Link.txt
# End Source File
# Begin Source File
SOURCE=..\..\Public\SCR\New.txt
# End Source File
# End Group
# Begin Source File
SOURCE=.\Scr.mak
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,719 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="SCR"
ProjectGUID="{DC5E18F8-C962-42A1-AFE2-61D45D35015F}"
SccProjectName="&quot;$/cpa/TempGrp/SCR&quot;, QEAAAAAA"
SccAuxPath=""
SccLocalPath="."
SccProvider="MSSCCI:NXN alienbrain"
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="X:\CPA\Libd"
IntermediateDirectory=".\Tmp\SCRP5_vd"
ConfigurationType="4"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="X:\CPA\Public"
PreprocessorDefinitions="_DEBUG;VISUAL;WIN32;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;SCR_DM_OptCFiles"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Tmp\SCRP5_vd/SCR.pch"
AssemblerListingLocation=".\Tmp\SCRP5_vd/"
ObjectFile=".\Tmp\SCRP5_vd/"
ProgramDataBaseFileName=".\Tmp\SCRP5_vd/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="X:\CPA\Libd\SCRP5_vd.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug Protected|Win32"
OutputDirectory="x:\CPA\Lib"
IntermediateDirectory=".\Tmp\SCRP5_vp"
ConfigurationType="4"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="X:\CPA\Public"
PreprocessorDefinitions="_DEBUG;VISUAL;WIN32;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;SCR_DM_OptCFiles;SCR_DM_ProtectedVersion"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Tmp\SCRP5_vp/SCR.pch"
AssemblerListingLocation=".\Tmp\SCRP5_vp/"
ObjectFile=".\Tmp\SCRP5_vp/"
ProgramDataBaseFileName=".\Tmp\SCRP5_vp/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="X:\CPA\Libd\SCRP5_vd.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="x:\cpa\lib"
IntermediateDirectory=".\Tmp\Release"
ConfigurationType="4"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="X:\CPA\Public"
PreprocessorDefinitions="NDEBUG;VISUAL;WIN32;USE_PROFILER;SCR_DM_OptCFiles"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Tmp\Release/SCR.pch"
AssemblerListingLocation=".\Tmp\Release/"
ObjectFile=".\Tmp\Release/"
ProgramDataBaseFileName=".\Tmp\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="X:\CPA\Lib\SCRP5_vr.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter=".c">
<File
RelativePath="SCR_Anl.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Bin.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Cxt.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_DyAr.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Err.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_File.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Hash.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Link.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Mem.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Ntfy.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Page.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Pars.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_RdL0.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Sect.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_SvL0.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_SvL1.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="SCR_Vars.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug Protected|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="">
<File
RelativePath="..\..\public\SCR\ErrScr.h">
</File>
<File
RelativePath="..\..\public\SCR\MmgScr.h">
</File>
<File
RelativePath="..\..\Public\SCR.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Anl.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Cfg.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_CFil.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Cxt.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Dbg.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_DyAr.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Err.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_File.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Hash.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Link.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Mem.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Ntfy.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Page.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Pars.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_RdL0.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Sect.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_SvL0.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_SvL1.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_Vars.h">
</File>
<File
RelativePath="..\..\Public\SCR\SCR_XXXX.h">
</File>
</Filter>
<Filter
Name="Others"
Filter="txt">
<File
RelativePath="..\..\Public\SCR\Link.txt">
</File>
<File
RelativePath="..\..\Public\SCR\New.txt">
</File>
</Filter>
<File
RelativePath="Scr.mak">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,464 @@
#include "SCR.h"
#include <string.h>
char g_chEndSections=0;
void fn_v_Bin_Read( SCR_tdst_File_Description *_File, int _Length, void *_Dest )
{
char *pch=(char *)_Dest;
_File->lChangeInPos+=_Length;
if( _Length <= _File->p_stHandle->iCnt )
{
memcpy( _Dest, (void *)_File->p_stHandle->p_cCurrent, _Length );
_File->p_stHandle->iCnt-=_Length;
_File->p_stHandle->p_cCurrent+=_Length;
}
else
{
memcpy( _Dest, (void *)_File->p_stHandle->p_cCurrent, _File->p_stHandle->iCnt );
pch+=_File->p_stHandle->iCnt;
_Length-=_File->p_stHandle->iCnt;
while( _Length )
{
(_File)->p_stHandle->iCnt = SCR_M_fread((_File)->p_stHandle->p_cBase, 1, SCR_CV_ui_Cfg_SizeBufferFile, _File);
if(((_File)->p_stHandle->iCnt == 0) || ((_File)->p_stHandle->iCnt == -1))
{
(_File)->p_stHandle->iCnt = 0;
*pch = EOF;
break;
}
else
{
(_File)->p_stHandle->p_cCurrent = (_File)->p_stHandle->p_cBase;
if( _Length <= _File->p_stHandle->iCnt )
{
memcpy( (void *)pch, (void *)_File->p_stHandle->p_cCurrent, _Length );
_File->p_stHandle->iCnt-=_Length;
_File->p_stHandle->p_cCurrent+=_Length;
_Length=0;
}
else
{
memcpy( (void *)pch, (void *)_File->p_stHandle->p_cCurrent, _File->p_stHandle->iCnt );
pch+=_File->p_stHandle->iCnt;
_Length-=_File->p_stHandle->iCnt;
}
}
}
}
}
void fn_v_Bin_Skip( SCR_tdst_File_Description *_File, int _Length )
{
_File->lChangeInPos+=_Length;
if( _Length <= _File->p_stHandle->iCnt )
{
_File->p_stHandle->iCnt-=_Length;
_File->p_stHandle->p_cCurrent+=_Length;
}
else
{
_Length-=_File->p_stHandle->iCnt;
while( _Length )
{
(_File)->p_stHandle->iCnt = SCR_M_fread((_File)->p_stHandle->p_cBase, 1, SCR_CV_ui_Cfg_SizeBufferFile, _File);
if(((_File)->p_stHandle->iCnt == 0) || ((_File)->p_stHandle->iCnt == -1))
{
(_File)->p_stHandle->iCnt = 0;
break;
}
else
{
(_File)->p_stHandle->p_cCurrent = (_File)->p_stHandle->p_cBase;
if( _Length <= _File->p_stHandle->iCnt )
{
_File->p_stHandle->iCnt-=_Length;
_File->p_stHandle->p_cCurrent+=_Length;
_Length=0;
}
else
{
_Length-=_File->p_stHandle->iCnt;
}
}
}
}
}
char SCR_fn_ch_Bin_GetCHAR( SCR_tdst_File_Description *_File )
{
char ch;
fn_v_Bin_Read(_File, sizeof( char ), (void*)&ch);
return ch;
}
short SCR_fn_s_Bin_GetSHORT( SCR_tdst_File_Description *_File )
{
short s;
fn_v_Bin_Read(_File, sizeof( short ), (void*)&s);
return s;
}
long SCR_fn_l_Bin_GetLONG( SCR_tdst_File_Description *_File )
{
long l;
fn_v_Bin_Read(_File, sizeof( long ), (void*)&l);
return l;
}
unsigned char SCR_fn_uch_Bin_GetUCHAR( SCR_tdst_File_Description *_File )
{
unsigned char ch;
fn_v_Bin_Read(_File, sizeof( unsigned char ), (void*)&ch);
return ch;
}
unsigned short SCR_fn_us_Bin_GetUSHORT( SCR_tdst_File_Description *_File )
{
unsigned short s;
fn_v_Bin_Read(_File, sizeof( unsigned short ), (void*)&s);
return s;
}
unsigned long SCR_fn_ul_Bin_GetULONG( SCR_tdst_File_Description *_File )
{
unsigned long l;
fn_v_Bin_Read(_File, sizeof( unsigned long ), (void*)&l);
return l;
}
float SCR_fn_f_Bin_GetFLOAT( SCR_tdst_File_Description *_File )
{
float f;
fn_v_Bin_Read(_File, sizeof( float ), (void*)&f);
return f;
}
double SCR_fn_d_Bin_GetDOUBLE( SCR_tdst_File_Description *_File )
{
double d;
fn_v_Bin_Read(_File, sizeof( double ), (void*)&d);
return d;
}
char * SCR_fn_sz_Bin_GetSTRING( SCR_tdst_File_Description *_File )
{
short s=SCR_fn_s_Bin_GetSHORT( _File );
char *sz;
SCR_M_Mem_Alloc(char, sz, s+1);
fn_v_Bin_Read( _File, s, (void *)sz );
sz[s]=0;
return sz;
}
int SCR_fn_sz_Bin_GetSTRING2Buffer( SCR_tdst_File_Description *_File, char *sz )
{
short s=SCR_fn_s_Bin_GetSHORT( _File );
fn_v_Bin_Read( _File, s, (void *)sz );
sz[s]=0;
return s;
}
void * SCR_fn_p_Bin_GetARRAY( SCR_tdst_File_Description *_File, short sIze )
{
short s=SCR_fn_s_Bin_GetSHORT( _File );
char *sz;
SCR_M_Mem_Alloc(char, sz, s*sIze);
fn_v_Bin_Read( _File, s*sIze, (void *)sz );
return (void *)sz;
}
void SCR_fn_sz_Bin_GetREFERENCE2Buffer( SCR_tdst_File_Description *_File, char* sz )
{
unsigned short usVal, usLast, usIsIndex;
int i=0;
do{
usVal=SCR_fn_us_Bin_GetUSHORT( _File );
usLast=usVal&0x4000;
usIsIndex=usVal&0x8000;
usVal&=0x3FFF;
if( usIsIndex )
{
strcpy( sz+i, _File->p_stRefs->a_szRefName[usVal] );
i+=strlen( _File->p_stRefs->a_szRefName[usVal] );
}
else
{
fn_v_Bin_Read( _File, usVal, sz+i );
i+=usVal;
}
} while ( !usLast );
sz[i]=0;
}
static char buffer[200];
char *SCR_fn_sz_Bin_GetREFERENCE( SCR_tdst_File_Description *_File )
{
unsigned short usVal, usLast, usIsIndex;
int i=0;
char *retVal;
do{
usVal=SCR_fn_us_Bin_GetUSHORT( _File );
usLast=usVal&0x4000;
usIsIndex=usVal&0x8000;
usVal&=0x3FFF;
if( usIsIndex )
{
strcpy( buffer+i, _File->p_stRefs->a_szRefName[usVal] );
i+=strlen( _File->p_stRefs->a_szRefName[usVal] );
}
else
{
fn_v_Bin_Read( _File, usVal, buffer+i );
i+=usVal;
}
} while ( !usLast );
buffer[i]=0;
SCR_M_Mem_Alloc(char, retVal, i);
strcpy( retVal, buffer );
return retVal;
}
void SCR_fn_v_Bin_BeginSection( SCR_tdst_File_Description *_p_stFile )
{
unsigned short us;
us=SCR_fn_us_Bin_GetUSHORT( _p_stFile );
if( us==0xFFFF )
{
_p_stFile->lToEndSection=SCR_fn_l_Bin_GetLONG( _p_stFile )+6;
_p_stFile->lChangeInPos=6;
}
else
{
_p_stFile->lToEndSection=(long)us+2;
_p_stFile->lChangeInPos=2;
}
}
short fn_s_Bin_SectionName( SCR_tdst_File_Description *_File, char * _p_szAction, char * _p_szId )
{
char *pch;
short s=SCR_fn_sz_Bin_GetSTRING2Buffer( _File, _p_szAction );
pch=strchr( _p_szAction, ':' );
if( pch )
{
strcpy( _p_szId, pch+1 );
*pch=0;
}
else _p_szId[0]=0;
return s+2;
}
void fn_v_Bin_Line(
SCR_tdst_File_Description *_p_stFile,
char *_p_szKeyword1,
char *_p_szKeyword2,
char *_p_szKeyword3,
char *_p_szKeyword4,
SCR_tde_Cxt_ParseType *_p_eParseType,
unsigned int *_p_uiNbRead
)
{
char sTag;
*_p_uiNbRead=0;
if( _p_stFile->lCountEndSections==-1 )
{
*_p_uiNbRead=_p_stFile->lToEndSection;
_p_stFile->lCountEndSections=0;
}
if( _p_stFile->lCountEndSections>0 )
{
*_p_eParseType=SCR_EPT_Cxt_EndSection;
*_p_uiNbRead=_p_stFile->lToEndSection;
_p_stFile->lToEndSection=0;
_p_stFile->lCountEndSections--;
return;
}
sTag=SCR_fn_ch_Bin_GetCHAR( _p_stFile ); /* get type tag */
if( sTag>0 )
{
*_p_eParseType=SCR_EPT_Cxt_Entry;
_p_szKeyword1[0]=sTag;
*_p_uiNbRead+=1;
return;
}
switch( sTag )
{
case TAG_BEGINSECTION:
/* Get section name (action + id) */
*_p_uiNbRead+=fn_s_Bin_SectionName(_p_stFile, _p_szKeyword1, _p_szKeyword2);
*_p_eParseType = SCR_EPT_Cxt_BeginSection;
break;
case TAG_EOF:
case TAG_COMMENT:
*_p_eParseType = SCR_EPT_Cxt_None;
break;
default: /* it is a directive then... */
/**_p_eParseType = SCR_EPT_Cxt_None;*/
_p_szKeyword4[0]=sTag;
*_p_eParseType = SCR_EPT_Cxt_Directive;
break;
}
*_p_uiNbRead+=1;
return;
}
long fn_l_Bin_ToEndSection( SCR_tdst_Cxt_Description *p_stContext )
{
long l,l1;
char ch;
unsigned short us=SCR_fn_us_Bin_GetUSHORT( &p_stContext->p_stOpenFile->stFile );
if( us!=0xFFFF )
{
l=us-1;
l1=us+2;
}
else
{
l=SCR_fn_l_Bin_GetLONG( &p_stContext->p_stOpenFile->stFile )-1;
l1=l+7;
}
fn_v_Bin_Skip( &p_stContext->p_stOpenFile->stFile, l );
ch=SCR_fn_ch_Bin_GetCHAR( &p_stContext->p_stOpenFile->stFile );
if( ch<=0 )
p_stContext->p_stOpenFile->stFile.lCountEndSections=-ch+1;
return l1;
}
void SCR_fn_v_Bin_EndSection( SCR_tdst_File_Description *_p_stFile )
{
char ch;
ch=SCR_fn_ch_Bin_GetCHAR( _p_stFile );
if( ch<=0 )
_p_stFile->lCountEndSections=-ch+1;
else
_p_stFile->lCountEndSections=-1;
}
SCR_tdst_Cxt_Values *SCR_fnp_st_Bin_GetREFERENCE( char *szName )
{
SCR_tdst_Cxt_Description *cxt=fnp_st_Cxt_Compute(0);
SCR_tdst_File_Description *_file=&cxt->p_stOpenFile->stFile;
long lPosition=cxt->stPosition.lAfterSeekInFile;
long lToEndSection, lChangeInPos;
SCR_tdst_Cxt_Values *p_stVal;
int _iRes;
lChangeInPos=_file->lChangeInPos;
lToEndSection=_file->lToEndSection;
if( cxt->p_stOpenFile->stParsingInfos.stPosition.lAfterSeekInFile<lPosition+lToEndSection )
{
fn_v_Bin_Skip( _file, lToEndSection-lChangeInPos-1 );
SCR_fn_v_Bin_EndSection( _file );
cxt->p_stOpenFile->stParsingInfos.stPosition.lAfterSeekInFile=lPosition+lToEndSection;
}
_file->lChangeInPos=_file->lToEndSection=0;
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szName, SCR_CDF_uw_Anl_Normal);
cxt->stPosition.lAfterSeekInFile=lPosition;
_file->lChangeInPos=lChangeInPos;
_file->lToEndSection=lToEndSection;
SCR_M_fseek(_file, lPosition+lChangeInPos, SEEK_SET, _iRes);
return p_stVal;
}
long fn_l_Bin_AnalyseDirective(SCR_tdst_Cxt_Description *_p_stContext)
{
char chDirective;
long l=0;
chDirective = _p_stContext->stBuffers.a_szBufferParams[0];
/*
* Test all directives.
*/
switch( chDirective )
{
case SCR_CD_w_Cfg_BreakPoint:
case SCR_CD_w_Cfg_UpdateLog:
case SCR_CD_w_Cfg_Comments:
case SCR_CD_w_Cfg_EndComments:
case SCR_CD_w_Cfg_NotSaveSection:
case SCR_CD_w_Cfg_EndNotSaveSection:
l+=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile )+2;
fn_v_Bin_Skip( &_p_stContext->p_stOpenFile->stFile, l );
break;
case SCR_CD_w_Cfg_ForceAnalyse:
{
l+=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile )+2;
fn_v_Bin_Skip( &_p_stContext->p_stOpenFile->stFile, l );
if(_p_stContext->p_stOpenFile->stParsingInfos.uwDynamicFlags & SCR_CDF_uw_Anl_ForceAnalyse)
{
SCR_M_Err_UpdateSyntaxError();
sprintf(g_st_Err_GlobalError.a_szBufferTmp2, "Directive is \"%s\".", SCR_CD_sz_Cfg_ForceAnalyse );
SCR_M_Err_RaiseWarning(SCR_EI_Err_UnnecessaryDirective);
}
else
_p_stContext->p_stOpenFile->stParsingInfos.uwDynamicFlags |= SCR_CDF_uw_Anl_ForceAnalyse;
}
break;
case SCR_CD_w_Cfg_EndForceAnalyse:
{
l+=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile )+2;
fn_v_Bin_Skip( &_p_stContext->p_stOpenFile->stFile, l );
if((_p_stContext->p_stOpenFile->stParsingInfos.uwDynamicFlags & SCR_CDF_uw_Anl_ForceAnalyse) == 0)
{
SCR_M_Err_UpdateSyntaxError();
sprintf(g_st_Err_GlobalError.a_szBufferTmp2, "Directive is \"%s\".", SCR_CD_sz_Cfg_EndForceAnalyse);
SCR_M_Err_RaiseWarning(SCR_EI_Err_UnnecessaryDirective);
}
else
_p_stContext->p_stOpenFile->stParsingInfos.uwDynamicFlags &= ~SCR_CDF_uw_Anl_ForceAnalyse;
}
break;
case SCR_CD_w_Cfg_SetCurrentFileLong:
{
short s1, s2;
l+=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile )+2;
s1=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile );
s2=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile );
SCR_M_RdL0_SetFileLong(0, s1, s2 );
}
break;
case SCR_CD_w_Cfg_SetCurrentFileDouble:
{
short s;
double d;
l+=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile )+2;
s=SCR_fn_s_Bin_GetSHORT( &_p_stContext->p_stOpenFile->stFile );
d=SCR_fn_d_Bin_GetDOUBLE( &_p_stContext->p_stOpenFile->stFile );
SCR_M_RdL0_SetFileDouble(0, s, d);
}
break;
}
return l;
}

View File

@@ -0,0 +1,154 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Cxt.c
* Contexts.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* Array of all contexts.
*/
SCR_tdst_DyAr_Description SCR_g_st_Cxt_Array;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Cxt_InitModule(void)
{
fn_v_DyAr_InitArray(&SCR_g_st_Cxt_Array);
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Cxt_CloseModule(void)
{
SCR_M_DyAr_DeleteAllElementsStatic(SCR_tdst_Cxt_Description, &SCR_g_st_Cxt_Array, ;);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To Add one open context.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Cxt_Description *fnp_st_Cxt_Add(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_Cxt_Description *p_stContext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Add element */
SCR_M_DyAr_AddElementStatic(SCR_tdst_Cxt_Description, uiPos, p_stContext, SCR_g_st_Cxt_Array);
/* Return result */
return p_stContext;
}
/*
*-------------------------------------------------------------------------------------------------
* To delete the last open context.
* g_ui_Cxt_CurrentContext is decreased, but context is kept.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Cxt_DeleteLast(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(SCR_M_Cxt_GetCurrentContext() >= 0);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_g_st_Cxt_Array.d_stDynArray[SCR_M_Cxt_GetCurrentContext()].eState = SCR_EDAS_DyAr_Free;
SCR_g_st_Cxt_Array.uiNumValues--;
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To compute a context with a specific offset.
* If offset is out uiMaxValues, we force allocation of a new set of contexts.
* If offset is out uiNumValues, we allocate it if it was not done before.
* _iOffset : Offset to get.
* Returns address of structure.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Cxt_Description *fnp_st_Cxt_Compute(int _iOffset)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int iLevel = SCR_M_Cxt_GetCurrentContext() + _iOffset;
unsigned int uiMemo;
SCR_tdst_Cxt_Description *p_stContext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(iLevel >= 0);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* To be sure that dynamic array is big enough.
* Else we (re)allocate array until it is big enough to return the asked context.
*/
while(iLevel >= (int) SCR_g_st_Cxt_Array.uiMaxValues)
{
uiMemo = SCR_g_st_Cxt_Array.uiNumValues;
SCR_g_st_Cxt_Array.uiNumValues = SCR_g_st_Cxt_Array.uiMaxValues;
p_stContext = fnp_st_Cxt_Add();
SCR_g_st_Cxt_Array.d_stDynArray[SCR_g_st_Cxt_Array.uiNumValues].eState = SCR_EDAS_DyAr_Free;
SCR_g_st_Cxt_Array.uiNumValues = uiMemo;
}
/*
* To be sure that context has been allocated at the given position.
*/
if
(
(iLevel >= (int) SCR_g_st_Cxt_Array.uiNumValues)
&& (SCR_g_st_Cxt_Array.d_stDynArray[iLevel].d_vElement == NULL)
)
{
fn_v_Mem_SetMode(0);
SCR_M_Mem_AllocAndSet
(
SCR_tdst_Cxt_Description,
p_stContext,
1
);
SCR_g_st_Cxt_Array.d_stDynArray[iLevel].d_vElement = (void *) p_stContext;
SCR_M_Dbg_UpdateSizeOf_P(SCR_tdst_Cxt_Description, p_stContext);
}
else
{
p_stContext = (SCR_tdst_Cxt_Description *) SCR_g_st_Cxt_Array.d_stDynArray[iLevel].d_vElement;
}
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Cxt_Description, p_stContext);
SCR_M_Dbg_Assert_P(SCR_g_st_Cxt_Array.d_stDynArray[iLevel].d_vElement != NULL);
return p_stContext;
}

View File

@@ -0,0 +1,127 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_DyAr.c
* Dynamic array
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* To initialize a dynamic array.
* _p_stArray : Array to initialize.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_DyAr_InitArray(SCR_tdst_DyAr_Description *_p_stArray)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stArray != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
_p_stArray->d_stDynArray = NULL;
_p_stArray->uiNumValues = 0;
_p_stArray->uiMaxValues = 0;
}
/*
*-------------------------------------------------------------------------------------------------
* To add a new element to a dynamic array.
* _p_stArray : Array concerned.
* _p_vElement : Element to add
* _cInitMem : Initialise the eventual allocated memory ?
* Returns index of allocated place, uiMaxValues in case of error.
*-------------------------------------------------------------------------------------------------
*/
unsigned int fn_ui_DyAr_AllocateElement(SCR_tdst_DyAr_Description *_p_stArray, char _cInitMem)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
unsigned int uiLastMax;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Mem_SetMode(0);
/*
* We searched a free place in array. If uiIndex is equal to uiMaxValues, that means
* that array is full and needs to be reallocate.
*/
uiIndex = _p_stArray->uiNumValues;
/* Need an allocation ? */
if(uiIndex == _p_stArray->uiMaxValues)
{
uiLastMax = _p_stArray->uiMaxValues;
_p_stArray->uiMaxValues += SCR_C_ui_DyAr_BaseForAllocation; /* Can be 0 */
/*
* Is there's an already allocated array ? If it's the case, we realloc it.
*/
if(_p_stArray->d_stDynArray)
{
SCR_M_Mem_Realloc
(
SCR_tdst_DyAr_Element,
_p_stArray->d_stDynArray,
_p_stArray->d_stDynArray,
_p_stArray->uiMaxValues,
SCR_C_ui_DyAr_BaseForAllocation
);
if(_cInitMem)
{
memset
(
&_p_stArray->d_stDynArray[uiLastMax],
0,
(_p_stArray->uiMaxValues - uiLastMax) * sizeof(SCR_tdst_DyAr_Element)
);
}
}
/*
* Else we create a new one
*/
else
{
if(_cInitMem)
{
SCR_M_Mem_AllocAndSet
(
SCR_tdst_DyAr_Element,
_p_stArray->d_stDynArray,
SCR_C_ui_DyAr_BaseForAllocation
);
}
else
{
SCR_M_Mem_Alloc
(
SCR_tdst_DyAr_Element,
_p_stArray->d_stDynArray,
SCR_C_ui_DyAr_BaseForAllocation
);
}
}
}
/*
* One more value in array.
*/
_p_stArray->uiNumValues++;
/* Returns index */
return uiIndex;
}

View File

@@ -0,0 +1,369 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Err.c
* Error managment.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <setjmp.h>
#include <windows.h>
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* List of all errors.
*/
SCR_tdst_Err_Description g_a_st_Err_ListErrors[] =
{
/*
* Errors.
*/
#ifdef _DEBUG
SCR_EI_Err_AssertionFailed, "Assertion failed.",
#endif /* _DEBUG */
SCR_EI_Err_EndSectionAlone, "End section was found without associated beginning.",
SCR_EI_Err_MissingEndSection, "End of section was not found.",
SCR_EI_Err_MissingEndSectionMark, "End-Mark of section name is missing.",
SCR_EI_Err_MissingEndFormatMark, "Special character to indicate the end of format is missing.",
SCR_EI_Err_MissingEndPostFormatMark,"Special character to indicate the end of post format is missing.",
SCR_EI_Err_MissingEndStringMark, "Special character to indicate the end of string is missing.",
SCR_EI_Err_MissingEndParamsMark, "Special character to indicate the end of list of parameters is missing.",
SCR_EI_Err_MissingEndVarMark, "Special character to indicate the end of variable is missing.",
SCR_EI_Err_MissingParameters, "List of parameters is missing.",
SCR_EI_Err_MissingDirectiveName, "Found directive special character without directive name.",
SCR_EI_Err_CorruptEndOfLine, "End of line is not correct, attempt for a return or eof.",
SCR_EI_Err_ReadFile, "Error while reading a file.",
SCR_EI_Err_OpenFile, "Unable to open file.",
SCR_EI_Err_CloseFile, "Unable to close file.",
SCR_EI_Err_WriteFile, "Unable to write to file.",
SCR_EI_Err_CreatePath, "Unable to create path",
SCR_EI_Err_NotEnoughMemory, "Not enough memory.",
SCR_EI_Err_AlreadyRegistered, "Section already registered.",
SCR_EI_Err_UnknownSection, "Unknown section searched.",
SCR_EI_Err_UnknownDirective, "Unknown directive.",
SCR_EI_Err_UnknownVariable, "Unknown variable.",
SCR_EI_Err_UnknownFormat, "Unknown format.",
SCR_EI_Err_BadCharacter, "Bad character read.",
SCR_EI_Err_BadNumParamsAR, "Bad number of parameters for array of references.",
SCR_EI_Err_BadNumParamsScanf, "Bad number of parameters for scanf format.",
SCR_EI_Err_UnknownDynamicFlag, "Unknown dynamic flag for automatic reference.",
SCR_EI_Err_CantConvertScanfFormat, "Can't convert a parameter with a scanf type format.",
/*
* Warnings.
*/
SCR_EI_Err_UnnecessaryDirective, "Unnecessary directive, ignored.",
SCR_EI_Err_SectionWithoutCallback, "Section without callback, ignored.",
/*
* Others...
*/
SCR_EI_Err_BadFileName, "Bad file name for a CD.", /* Fatal error */
};
/*
* To raise an error, and callback.
*/
SCR_tdst_Err_GlobalError g_st_Err_GlobalError;
SCR_tdst_Err_Context g_a_st_Err_Context[SCR_CV_ui_Cfg_MaxErrContext];
int g_i_Err_CurrentContext;
SCR_tdpfn_Err_Callback SCR_g_pfn_Err_Callback;
unsigned short SCR_g_uw_Err_Mode;
int g_i_Err_GlobalReturn;
/*
* Name of log file when init error module.
*/
static char gs_a_szInitLogName[_MAX_PATH];
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_InitModule(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
FILE *p_xFile;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Delete "SCR_Err.log" file.
* Compute in gs_a_szInitLogName the full path to access log file (just in case
* of a chdir call in a load).
*/
gs_a_szInitLogName[0] = '\0';
p_xFile = fopen(SCR_CL_sz_Cfg_LogFileName, "wt");
if(p_xFile)
{
if(_fullpath(gs_a_szInitLogName, SCR_CL_sz_Cfg_LogFileName, _MAX_PATH) == NULL)
strcat(gs_a_szInitLogName, SCR_CL_sz_Cfg_LogFileName);
fclose(p_xFile);
unlink(gs_a_szInitLogName);
}
else
unlink(SCR_CL_sz_Cfg_LogFileName);
/*
* No global error callback.
* Current error context is -1 (none).
* Clear error.
*/
SCR_g_pfn_Err_Callback = NULL;
SCR_g_uw_Err_Mode = SCR_CM_Err_Normal;
g_i_Err_CurrentContext = -1;
SCR_fn_v_RdL0_ClearError();
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_CloseModule(void)
{
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To initialize g_st_Err_GlobalError structure.
* eErrorId, p_szFileName, iLineInFile and a_szBufferTmp must be correct.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_InitGlobalError(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
char a_szTemp[SCR_CV_ui_Cfg_MaxLenError];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Get error structure associated to eErrorId (to obtain info string).
*/
uiIndex = 0;
while(g_a_st_Err_ListErrors[uiIndex].eErrorId != g_st_Err_GlobalError.eErrorId)
uiIndex++;
/* Info string */
strcpy
(
g_st_Err_GlobalError.a_szBufferOut,
g_a_st_Err_ListErrors[uiIndex].p_szInfoString
);
strcat(g_st_Err_GlobalError.a_szBufferOut, "\n");
/* Informations about source file */
sprintf
(
a_szTemp,
"Error was raised in source file \"%s\" at line \"%d\".\n",
g_st_Err_GlobalError.p_szFileName,
g_st_Err_GlobalError.iLineInFile
);
strcat(g_st_Err_GlobalError.a_szBufferOut, a_szTemp);
/* Separator */
if((*g_st_Err_GlobalError.a_szBufferTmp1) || (*g_st_Err_GlobalError.a_szBufferTmp1))
strcat(g_st_Err_GlobalError.a_szBufferOut, "----------\n");
/* Additional info string 1 */
strcat(g_st_Err_GlobalError.a_szBufferOut, g_st_Err_GlobalError.a_szBufferTmp1);
/* Additional info string 2 */
strcat(g_st_Err_GlobalError.a_szBufferOut, g_st_Err_GlobalError.a_szBufferTmp2);
}
/*
*-------------------------------------------------------------------------------------------------
* To raise an error.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_SetError(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
FILE *p_xFile;
SCR_tdst_Cxt_Description *p_stContext;
int iCpt;
#endif /* _DEBUG */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Initialize global error.
*/
fn_v_Err_InitGlobalError();
#ifdef _DEBUG
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Err_UpdateLogFile();
if((SCR_g_uw_Err_Mode & SCR_CM_Err_NotUpdateLog) == 0)
{
if(*gs_a_szInitLogName)
{
p_xFile = fopen(gs_a_szInitLogName, "at");
if(p_xFile == NULL)
p_xFile = fopen(gs_a_szInitLogName, "wt");
if(p_xFile)
{
iCpt = SCR_g_st_Cxt_Array.uiNumValues;
while(iCpt)
{
fprintf(p_xFile, "\n<** Context %d **>\n", iCpt - SCR_g_st_Cxt_Array.uiNumValues);
p_stContext = fnp_st_Cxt_Compute(iCpt - SCR_g_st_Cxt_Array.uiNumValues);
if(p_stContext->p_stOpenFile)
fprintf(p_xFile, "File : %s\n", p_stContext->p_stOpenFile->stFile.a_szOpenFileName);
if(p_stContext->p_stSectionDes)
fprintf(p_xFile, "Section : %s\n", p_stContext->p_stSectionDes->stBuffers.p_szBufferCompleteName);
else if(p_stContext->p_stOpenFile)
fprintf(p_xFile, "Section : %s\n", p_stContext->p_stOpenFile->stFile.a_szOpenFileName);
iCpt--;
}
fclose(p_xFile);
}
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif /* _DEBUG */
/*
* If there's an error callback, call it and restore context to return script parser.
*/
if(SCR_g_pfn_Err_Callback)
{
SCR_g_pfn_Err_Callback(&g_st_Err_GlobalError);
SCR_M_Err_RestoreContext();
}
/*
* Display the message.
*/
g_i_Err_GlobalReturn = fn_i_Err_DisplayError
(
"Fatal error - Script parser aborted",
g_st_Err_GlobalError.a_szBufferOut
);
switch(g_i_Err_GlobalReturn)
{
case IDRETRY:
return;
default:
break;
}
/*
* Stop parser.
* The file whose name if define with SCR_C_sz_Cfg_LogFileName (constant in "SCR_Cfg.h")
* contains the same informations that the previous dialog box.
*
* Good luck to find the error !!!
*/
SCR_M_Dbg_BreakForDebug();
exit(0);
}
/*
*-------------------------------------------------------------------------------------------------
* To raise a warning.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_SetWarning(void)
{
/*
* Initialize global error.
*/
fn_v_Err_InitGlobalError();
/*
* Update .log file.
*/
fn_v_Err_UpdateLogFile();
/*
* Clear error (cause it's a warning).
*/
SCR_fn_v_RdL0_ClearError();
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To update log file.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Err_UpdateLogFile(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
FILE *p_xFile;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if((SCR_g_uw_Err_Mode & SCR_CM_Err_NotUpdateLog) == 0)
{
if(*gs_a_szInitLogName)
{
p_xFile = fopen(gs_a_szInitLogName, "at");
if(p_xFile == NULL)
p_xFile = fopen(gs_a_szInitLogName, "wt");
if(p_xFile)
{
fprintf(p_xFile, "%s", g_st_Err_GlobalError.a_szBufferOut);
fprintf(p_xFile, "\n----------------(:-)----------------\n\n");
fclose(p_xFile);
}
}
}
}
/*
*-------------------------------------------------------------------------------------------------
* To say to user that a fatal error occured.
* _Type : A string to indicate the type of error.
* _Info : A string that describes the error.
*-------------------------------------------------------------------------------------------------
*/
int fn_i_Err_DisplayError(char *_p_szType, char *_p_szInfo)
{
unsigned int uiStyle;
if((SCR_g_uw_Err_Mode & SCR_CM_Err_NotDisplayInfos) == 0)
{
/* Change message box style depending on error */
switch(g_st_Err_GlobalError.eErrorId)
{
case SCR_EI_Err_OpenFile:
uiStyle = MB_RETRYCANCEL|MB_ICONERROR;
break;
default:
uiStyle = MB_OK|MB_ICONERROR;
break;
}
/* Display message box */
return Erm_fn_iMessageBox
(
_p_szInfo,
_p_szType,
uiStyle
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,148 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Hash.c
* To manage hash table.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <ctype.h>
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init a hash table.
* _p_stHash : Array to init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Hash_InitTable(SCR_tda_st_Hash_Table _p_stHash)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiEntry;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stHash != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for(uiEntry = 0 ; uiEntry < SCR_C_ui_Hash_Size; uiEntry++)
{
fn_v_DyAr_InitArray(&_p_stHash[uiEntry]);
}
}
/*
*-------------------------------------------------------------------------------------------------
* Close a hash table.
* _p_stHash : Array to close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Hash_CloseTable(SCR_tda_st_Hash_Table _p_stHash)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiEntry;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stHash != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for(uiEntry = 0 ; uiEntry < SCR_C_ui_Hash_Size; uiEntry++)
{
SCR_M_DyAr_DeleteAllElements(SCR_tdst_Hash_Value, &_p_stHash[uiEntry], ;);
}
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Compute a hash value for a string
* _p_szString : String to get hash value.
* Returns hash value computed.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdx_Hash_Key SCR_fn_x_Hash_ComputeHashKeyForString(char *_p_szString)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiKey = 0;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szString != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* We compute an hash value for any strings.
*/
while(*_p_szString)
{
uiKey = (uiKey << 5) + uiKey + tolower(*_p_szString);
_p_szString++;
}
return uiKey % SCR_C_ui_Hash_Modulo;
}
/*
*-------------------------------------------------------------------------------------------------
* Compute a hash value for a long
* _lValue : Long to get hash value.
* Returns hash value computed.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdx_Hash_Key SCR_fn_x_Hash_ComputeHashKeyForLong(long _lValue)
{
return(((SCR_tdx_Hash_Key) _lValue >> 4) % SCR_C_ui_Hash_Modulo);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Add a value at a specified Hash position in a table.
* _xHashKey : Hash key
* _p_stHashTable : Hash table
* _ulValue : Value to add
* _p_uiIndexOfHashValue : To receive index of hash value in table.
* Returns address of allocated structure.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Hash_Value *fnp_st_Hash_AddValue
(
SCR_tdx_Hash_Key _xHashKey,
SCR_tda_st_Hash_Table _p_stHashTable,
unsigned long _ulValue,
unsigned int *_p_uiIndexOfHashValue
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Hash_Value *p_stHashValue;
unsigned int uiIndex;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stHashTable != NULL);
SCR_M_Dbg_Assert_P(_xHashKey < SCR_C_ui_Hash_Size);
SCR_M_Dbg_Assert_P(_p_uiIndexOfHashValue != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Add element in Hash table
*/
SCR_M_DyAr_AddElement(SCR_tdst_Hash_Value, uiIndex, p_stHashValue, _p_stHashTable[_xHashKey]);
/*
* We set value at the returned position.
*/
p_stHashValue->ulValue = _ulValue;
*_p_uiIndexOfHashValue = uiIndex;
return p_stHashValue;
}

View File

@@ -0,0 +1,877 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Link.c
* To manage Link table.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/* Array of link tables */
SCR_tdst_DyAr_Description SCR_g_st_Link_Array;
#if defined SCR_DM_ProtectedVersion
void fn_v_Link_AssertValidP(SCR_tdst_Link_Table *_p_stLink, SCR_tdst_Link_Value *_p_stEntry)
{
SCR_M_Dbg_Assert_P
(
_p_stEntry->stHeader.ucMemLevel
== ((SCR_tdst_Hash_Value *) (_p_stLink->a_stHashTableForKeys[_p_stEntry->xHashKeyForKey]
.d_stDynArray[_p_stEntry->uiIndexHashKeyKey].d_vElement))
->stHeader.ucMemLevel
);
SCR_M_Dbg_Assert_P
(
_p_stEntry->stHeader.ucMemLevel
== ((SCR_tdst_Hash_Value *) (_p_stLink->a_stHashTableForValues[_p_stEntry->xHashKeyForValue]
.d_stDynArray[_p_stEntry->uiIndexHashKeyValue].d_vElement))
->stHeader.ucMemLevel
);
}
#else
#define fn_v_Link_AssertValidP(a, b)
#endif /* SCR_DM_ProtectedVersion */
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Link_InitModule(void)
{
fn_v_DyAr_InitArray(&SCR_g_st_Link_Array);
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Link_CloseModule(void)
{
unsigned int uiIndex;
/*
* Delete all elements.
*/
for(uiIndex = 0; uiIndex < SCR_g_st_Link_Array.uiNumValues; uiIndex++)
if(SCR_g_st_Link_Array.d_stDynArray[uiIndex].d_vElement != NULL)
{
SCR_M_DyAr_DeleteElementNoAlloc
(
uiIndex,
&SCR_g_st_Link_Array,
SCR_fn_v_Link_CloseTable((SCR_tdst_Link_Table *) _p_stElement_->d_vElement);
);
}
/*
* Free array.
*/
if(SCR_g_st_Link_Array.d_stDynArray)
{
fn_v_Mem_SetMode(0);
SCR_M_Mem_Free(SCR_g_st_Link_Array.d_stDynArray);
}
SCR_g_st_Link_Array.uiNumValues = SCR_g_st_Link_Array.uiMaxValues = 0;
}
/*
*-------------------------------------------------------------------------------------------------
* Function that checked if a link table has been register.
* _p_stLink : Link table to search.
* _p_uiIndex : To return (can be NULL) the index of the table in global array.
*-------------------------------------------------------------------------------------------------
*/
char fn_c_Link_CheckForInit(SCR_tdst_Link_Table *_p_stLink, unsigned int *_p_uiIndex)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
SCR_tdst_Link_Table *p_stTemp;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
uiIndex = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiIndex, p_stTemp, SCR_g_st_Link_Array);
while(p_stTemp)
{
if(p_stTemp == _p_stLink)
{
if(_p_uiIndex)
*_p_uiIndex = uiIndex;
return 1;
}
uiIndex++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiIndex, p_stTemp, SCR_g_st_Link_Array);
}
return 0;
}
/*
*-------------------------------------------------------------------------------------------------
* Init a link table.
* _p_stLink : Link table to init.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Link_InitTable(SCR_tdst_Link_Table *_p_stLink)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(!fn_c_Link_CheckForInit(_p_stLink, NULL))
{
/* Add table in array */
SCR_M_DyAr_AddElementNoAlloc(uiIndex, _p_stLink, SCR_g_st_Link_Array);
/* Init table */
SCR_M_Dbg_UpdateSizeOf_P(SCR_tdst_Link_Table, _p_stLink);\
fn_v_DyAr_InitArray(&_p_stLink->stLinkArray);
fn_v_Hash_InitTable(_p_stLink->a_stHashTableForValues);
fn_v_Hash_InitTable(_p_stLink->a_stHashTableForKeys);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* Really delete a link table.
* _p_stLink : Link table to delete.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Link_CloseTable(SCR_tdst_Link_Table *_p_stLink)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Delete element from table */
if(fn_c_Link_CheckForInit(_p_stLink, &uiIndex))
SCR_M_DyAr_DeleteElementNoAlloc(uiIndex, &SCR_g_st_Link_Array, ;);
/* Delete content */
SCR_M_DyAr_DeleteAllElements
(
SCR_tdst_Link_Value,
&_p_stLink->stLinkArray,
{
fn_v_Link_AssertValidP(_p_stLink, _p_stPointer_);
fn_v_Mem_SetMode(_p_stPointer_->stHeader.ucMemLevel);
SCR_M_Mem_Free(_p_stPointer_->p_szKey);
}
);
fn_v_Hash_CloseTable(_p_stLink->a_stHashTableForValues);
fn_v_Hash_CloseTable(_p_stLink->a_stHashTableForKeys);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Add an entry to a link table
* _p_stLink : Link table
* _p_szKey : String key of value
* _ulValue : Value to set in structure
* _eState : State of that value
* Returns pointer on added link.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Link_Value *SCR_fnp_st_Link_AddEntry
(
SCR_tdst_Link_Table *_p_stLink,
char *_p_szKey,
unsigned long _ulValue,
SCR_tde_Link_State _eState
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiIndex;
SCR_tdst_Link_Value *p_stLinkValue;
unsigned char ucMemoLevel;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
SCR_M_Dbg_Assert_D(_p_szKey != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/***************************************************/
ucMemoLevel = g_uc_Mem_CurrentMemLevel;
g_uc_Mem_CurrentMemLevel = g_uc_Mem_CurrentLinkLevel;
/***************************************************/
/* If assertion failed, link table has not been properly init with script function */
SCR_M_Dbg_Assert_D(fn_c_Link_CheckForInit(_p_stLink, NULL));
/*
* Add a new link value in link value array.
*/
SCR_M_DyAr_AddElement(SCR_tdst_Link_Value, uiIndex, p_stLinkValue, _p_stLink->stLinkArray);
/*
* Initialize structure.
*/
p_stLinkValue->eState = _eState;
p_stLinkValue->ulValue = _ulValue;
if(_eState == SCR_ELS_Link_Initialized)
{
p_stLinkValue->xHashKeyForValue = SCR_fn_x_Hash_ComputeHashKeyForLong(_ulValue);
fnp_st_Hash_AddValue
(
p_stLinkValue->xHashKeyForValue,
_p_stLink->a_stHashTableForValues,
(unsigned long) p_stLinkValue,
&p_stLinkValue->uiIndexHashKeyValue
);
}
else
{
/* Not initialized */
p_stLinkValue->xHashKeyForValue = SCR_C_ui_Hash_Modulo;
}
fn_v_Mem_SetMode(p_stLinkValue->stHeader.ucMemLevel);
SCR_M_Mem_Alloc(char, p_stLinkValue->p_szKey, strlen(_p_szKey) + 1);
strcpy(p_stLinkValue->p_szKey, _p_szKey);
p_stLinkValue->xHashKeyForKey = SCR_fn_x_Hash_ComputeHashKeyForString(_p_szKey);
fnp_st_Hash_AddValue
(
p_stLinkValue->xHashKeyForKey,
_p_stLink->a_stHashTableForKeys,
(unsigned long) p_stLinkValue,
&p_stLinkValue->uiIndexHashKeyKey
);
/*
* Initialize additional informations.
*/
memset(&p_stLinkValue->stInfos, 0, sizeof(SCR_tdst_Link_AdditionalInfos));
/***************************************************/
fn_v_Link_AssertValidP(_p_stLink, p_stLinkValue);
g_uc_Mem_CurrentMemLevel = ucMemoLevel;
/***************************************************/
SCR_RETURN(p_stLinkValue);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
/*
*-------------------------------------------------------------------------------------------------
* Get Link for a specific key. Create it if it does not exist yet.
* _p_stLink : Link table to search
* _p_szKey : String key of value
* Returns founded or created link.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Link_Value *SCR_fnp_st_Link_CreateOrGetLinkFromKey
(
SCR_tdst_Link_Table *_p_stLink,
char *_p_szKey
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Link_Value *p_stLinkValue;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
SCR_M_Dbg_Assert_D(_p_szKey != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* We first search if there's already a key in link table.
*/
p_stLinkValue = SCR_fnp_st_Link_SearchKey(_p_stLink, _p_szKey);
/*
* Key is not here, add it.
*/
if(p_stLinkValue == NULL)
{
p_stLinkValue = SCR_fnp_st_Link_AddEntry
(
_p_stLink,
_p_szKey,
0x12345678,
SCR_ELS_Link_NotInitialized
);
}
SCR_RETURN(p_stLinkValue);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
/*
*-------------------------------------------------------------------------------------------------
* Set the ulValue of a specific key.
* _p_stLink : Link table to search
* _p_szKey : String key of value
* _ulValue : Value to set
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Link_Value *SCR_fnp_st_Link_SetValue
(
SCR_tdst_Link_Table *_p_stLink,
char *_p_szKey,
unsigned long _ulValue
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Link_Value *p_stLinkValue;
unsigned char ucMemoLevel;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
SCR_M_Dbg_Assert_D(_p_szKey != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* We first search the key in the link table.
*/
p_stLinkValue = SCR_fnp_st_Link_SearchKey(_p_stLink, _p_szKey);
/*
* No key found, add one.
*/
if(p_stLinkValue == NULL)
{
SCR_RETURN(SCR_fnp_st_Link_AddEntry
(
_p_stLink,
_p_szKey,
_ulValue,
SCR_ELS_Link_Initialized
));
}
/*
* We have found an already registered link.
* Initialized the found structure.
*/
else
{
/*
* If value replaced another one, we must delete actual hash.
*/
if(p_stLinkValue->xHashKeyForValue != SCR_C_ui_Hash_Modulo)
{
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Hash_Value,
p_stLinkValue->uiIndexHashKeyValue,
&_p_stLink->a_stHashTableForValues[p_stLinkValue->xHashKeyForValue],
;
);
}
/*
* Initialize new value.
*/
/***************************************************/
ucMemoLevel = g_uc_Mem_CurrentMemLevel;
g_uc_Mem_CurrentMemLevel = p_stLinkValue->stHeader.ucMemLevel;
/***************************************************/
p_stLinkValue->ulValue = _ulValue;
p_stLinkValue->xHashKeyForValue = SCR_fn_x_Hash_ComputeHashKeyForLong(_ulValue);
p_stLinkValue->eState = SCR_ELS_Link_Initialized;
fnp_st_Hash_AddValue
(
p_stLinkValue->xHashKeyForValue,
_p_stLink->a_stHashTableForValues,
(unsigned long) p_stLinkValue,
&p_stLinkValue->uiIndexHashKeyValue
);
/***************************************************/
g_uc_Mem_CurrentMemLevel = ucMemoLevel;
/***************************************************/
SCR_RETURN(p_stLinkValue);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Search a key in a link table.
* _p_stLink : Link table to search
* _p_szKey : String key of value
* Returns pointer on found link or NULL.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Link_Value *SCR_fnp_st_Link_SearchKey
(
SCR_tdst_Link_Table *_p_stLink,
char *_p_szKey
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_DyAr_Description *p_stHashEntry;
SCR_tdst_Hash_Value *p_stHashValue;
SCR_tdst_Link_Value *p_stLinkValue;
SCR_tdx_Hash_Key xHashKey;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
SCR_M_Dbg_Assert_D(_p_szKey != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Compute hash key for given string
*/
xHashKey = SCR_fn_x_Hash_ComputeHashKeyForString(_p_szKey);
/*
* If there's no dynamic array associated to this hash key code,
* we are sure that data was not stored in the array.
*/
p_stHashEntry = &_p_stLink->a_stHashTableForKeys[xHashKey];
/*
* Else we search in the array (that contains all the datas with the
* same hash key code) if our data is present.
*/
uiPos = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Hash_Value, uiPos, p_stHashValue, (*p_stHashEntry));
while(p_stHashValue)
{
p_stLinkValue = (SCR_tdst_Link_Value *) p_stHashValue->ulValue;
if(!strcmpi(p_stLinkValue->p_szKey, _p_szKey))
SCR_RETURN(p_stLinkValue);
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Hash_Value, uiPos, p_stHashValue, (*p_stHashEntry));
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
/*
*-------------------------------------------------------------------------------------------------
* Search a value in a link table
* _p_stLink Link table to search
* _ulValue value to search for
* Returns pointer on found link or NULL
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Link_Value *SCR_fnp_st_Link_SearchValue
(
SCR_tdst_Link_Table *_p_stLink,
unsigned long _ulValue
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_DyAr_Description *p_stHashEntry;
SCR_tdst_Hash_Value *p_stHashValue;
SCR_tdst_Link_Value *p_stLinkValue;
SCR_tdx_Hash_Key xHashKey;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stLink != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Compute hash key for given string.
*/
xHashKey = SCR_fn_x_Hash_ComputeHashKeyForLong(_ulValue);
/*
* Get hash entry for computed Hash key code.
*/
p_stHashEntry = &_p_stLink->a_stHashTableForValues[xHashKey];
/*
* Else we search in the array (that contains all the datas with the
* same hash key code) if our data is present.
*/
uiPos = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Hash_Value, uiPos, p_stHashValue, (*p_stHashEntry));
while(p_stHashValue)
{
p_stLinkValue = (SCR_tdst_Link_Value *) p_stHashValue->ulValue;
if(p_stLinkValue->ulValue == _ulValue)
SCR_RETURN(p_stLinkValue);
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Hash_Value, uiPos, p_stHashValue, (*p_stHashEntry));
}
SCR_RETURN(NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
/*
*-------------------------------------------------------------------------------------------------
* Delete an entry in a link table.
* _p_stLink Link table to search
* _p_stEntry Entry to delete.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Link_DeleteEntry
(
SCR_tdst_Link_Table *_p_stLink,
SCR_tdst_Link_Value *_p_stEntry
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Link_AssertValidP(_p_stLink, _p_stEntry);
/*
* Delete in the two hash tables.
*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Hash_Value,
_p_stEntry->uiIndexHashKeyKey,
&_p_stLink->a_stHashTableForKeys[_p_stEntry->xHashKeyForKey],
;
);
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Hash_Value,
_p_stEntry->uiIndexHashKeyValue,
&_p_stLink->a_stHashTableForValues[_p_stEntry->xHashKeyForValue],
;
);
/*
* Delete link value in array.
*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Link_Value,
_p_stEntry->stHeader.uiIndexInArray,
&_p_stLink->stLinkArray,
{
fn_v_Mem_SetMode(_p_stPointer_->stHeader.ucMemLevel);
SCR_M_Mem_Free(_p_stPointer_->p_szKey);
}
);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
*/
/*
*-------------------------------------------------------------------------------------------------
* To save a link table on disk.
* _p_szName : Name of link table to save.
* _p_stLink : Link table to save.
* _p_CallBack : Call back that will be called for every entries saved.
*-------------------------------------------------------------------------------------------------
*/
void _SCR_fn_v_Link_SaveOnDisk_
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink,
SCR_tdpfn_Link_Callback _p_CallBack
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
FILE *p_xHandle;
unsigned int uiPos, uiSizeOfKey;
SCR_tdst_Link_Value *p_stLinkValue;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* If assertion failed, link table has not been properly init with script function */
SCR_M_Dbg_Assert_D(fn_c_Link_CheckForInit(_p_stLink, NULL));
/*
* Pack table before saving.
* No save if table is empty.
*/
SCR_M_DyAr_PackArray(SCR_tdst_Link_Value, _p_stLink->stLinkArray, ;);
SCR_M_Hash_PackArray(_p_stLink->a_stHashTableForValues, SCR_tdst_Link_Value, _p_stLink->stLinkArray, xHashKeyForValue, uiIndexHashKeyValue);
SCR_M_Hash_PackArray(_p_stLink->a_stHashTableForKeys, SCR_tdst_Link_Value, _p_stLink->stLinkArray, xHashKeyForKey, uiIndexHashKeyKey);
if(_p_stLink->stLinkArray.uiNumValues == 0)
return;
/*
* Open the file for writing.
*/
p_xHandle = fopen(_p_szName, "wb");
if(p_xHandle == NULL)
{
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", _p_szName);
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
SCR_M_Err_RaiseError(SCR_EI_Err_OpenFile);
}
/*
* To save all elements...
*/
uiPos = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stLinkValue, _p_stLink->stLinkArray);
while(p_stLinkValue)
{
if(_p_CallBack)
_p_CallBack(p_stLinkValue);
/* Write length of key */
uiSizeOfKey = strlen(p_stLinkValue->p_szKey) + 1;
fwrite(&uiSizeOfKey, sizeof(int), 1, p_xHandle);
/* Write key */
fwrite(p_stLinkValue->p_szKey, uiSizeOfKey, 1, p_xHandle);
/* Write rest of structure */
fwrite(p_stLinkValue, sizeof(SCR_tdst_Link_Value), 1, p_xHandle);
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stLinkValue, _p_stLink->stLinkArray);
}
fclose(p_xHandle);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}
void SCR_fn_v_Link_SaveOnDisk
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink
)
SCR_BEGIN
_SCR_fn_v_Link_SaveOnDisk_(_p_szName, _p_stLink, NULL);
SCR_CEND(;)
void SCR_fn_v_Link_SaveOnDiskWithCallBack
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink,
SCR_tdpfn_Link_Callback _p_CallBack
)
SCR_BEGIN
_SCR_fn_v_Link_SaveOnDisk_(_p_szName, _p_stLink, _p_CallBack);
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To load a link table from disk.
* _p_szName : Name of link table to save.
* _p_stLink : Link table to save.
* _p_CallBack : Call back that will be called for every entries added in the array.
*-------------------------------------------------------------------------------------------------
*/
void _SCR_fn_v_Link_LoadFromDisk_
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink,
SCR_tdpfn_Link_Callback _p_CallBack
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
FILE *p_xHandle;
SCR_tdst_Link_Value stLinkValue, *p_stLinkValue;
unsigned int uiIndex, uiSizeOfKey;
unsigned char ucMemoLevel;
char *p_szTempKey;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* If assertion failed, link table has not been properly init with script function */
SCR_M_Dbg_Assert_D(fn_c_Link_CheckForInit(_p_stLink, NULL));
/*
* Open the file for reading.
*/
p_xHandle = fopen(_p_szName, "rb");
if(p_xHandle == NULL)
return;
/*
* Read the file.
*/
while(!feof(p_xHandle))
{
/* Read size of key */
if(fread(&uiSizeOfKey, sizeof(int), 1, p_xHandle))
{
fn_v_Mem_SetMode(g_uc_Mem_CurrentLinkLevel);
SCR_M_Mem_Alloc(char, p_szTempKey, uiSizeOfKey);
/* Read key */
if(fread(p_szTempKey, uiSizeOfKey, 1, p_xHandle))
{
/* Read structure */
if(fread(&stLinkValue, sizeof(SCR_tdst_Link_Value), 1, p_xHandle))
{
if(!SCR_fnp_st_Link_SearchKey(_p_stLink, p_szTempKey))
{
/***************************************************/
ucMemoLevel = g_uc_Mem_CurrentMemLevel;
g_uc_Mem_CurrentMemLevel = g_uc_Mem_CurrentLinkLevel;
/***************************************************/
/* Add a new link value */
SCR_M_DyAr_AddElement(SCR_tdst_Link_Value, uiIndex, p_stLinkValue, _p_stLink->stLinkArray);
/* Copy loaded value to this new one */
memcpy(p_stLinkValue, &stLinkValue, sizeof(SCR_tdst_Link_Value));
/* Init fields that can't be copied */
p_stLinkValue->p_szKey = p_szTempKey;
p_stLinkValue->stHeader.uiIndexInArray = uiIndex;
if(p_stLinkValue->eState == SCR_ELS_Link_Initialized)
{
fnp_st_Hash_AddValue
(
p_stLinkValue->xHashKeyForValue,
_p_stLink->a_stHashTableForValues,
(unsigned long) p_stLinkValue,
&p_stLinkValue->uiIndexHashKeyValue
);
}
fnp_st_Hash_AddValue
(
p_stLinkValue->xHashKeyForKey,
_p_stLink->a_stHashTableForKeys,
(unsigned long) p_stLinkValue,
&p_stLinkValue->uiIndexHashKeyKey
);
/***************************************************/
g_uc_Mem_CurrentMemLevel = ucMemoLevel;
/***************************************************/
/* Call the callback */
if(_p_CallBack)
_p_CallBack(p_stLinkValue);
}
else
{
fn_v_Mem_SetMode(g_uc_Mem_CurrentLinkLevel);
SCR_M_Mem_Free(p_szTempKey);
}
}
}
}
}
fclose(p_xHandle);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}
void SCR_fn_v_Link_LoadFromDisk
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink
)
SCR_BEGIN
_SCR_fn_v_Link_LoadFromDisk_(_p_szName, _p_stLink, NULL);
SCR_CEND(;)
void SCR_fn_v_Link_LoadFromDiskWithCallBack
(
char *_p_szName,
SCR_tdst_Link_Table *_p_stLink,
SCR_tdpfn_Link_Callback _p_CallBack
)
SCR_BEGIN
_SCR_fn_v_Link_LoadFromDisk_(_p_szName, _p_stLink, _p_CallBack);
SCR_CEND(;)
/*
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
*/
/*
*-------------------------------------------------------------------------------------------------
* To reduce memory size.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Link_ReduceMemory(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPosTables;
SCR_tdst_Link_Table *p_stLinkTable;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Pack array of link tables */
SCR_M_DyAr_PackArray(SCR_tdst_Link_Table, SCR_g_st_Link_Array, ;);
/* Pack all registered link tables */
uiPosTables = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiPosTables, p_stLinkTable, SCR_g_st_Link_Array);
while(p_stLinkTable)
{
SCR_M_DyAr_PackArray(SCR_tdst_Link_Value, p_stLinkTable->stLinkArray, ;);
SCR_M_Hash_PackArray(p_stLinkTable->a_stHashTableForValues, SCR_tdst_Link_Value, p_stLinkTable->stLinkArray, xHashKeyForValue, uiIndexHashKeyValue);
SCR_M_Hash_PackArray(p_stLinkTable->a_stHashTableForKeys, SCR_tdst_Link_Value, p_stLinkTable->stLinkArray, xHashKeyForKey, uiIndexHashKeyKey);
uiPosTables++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiPosTables, p_stLinkTable, SCR_g_st_Link_Array);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Link_DeleteWithMemLevel
(
unsigned char _ucMin,
unsigned char _ucMax
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPosTables;
SCR_tdst_Link_Table *p_stLinkTable;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
uiPosTables = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiPosTables, p_stLinkTable, SCR_g_st_Link_Array);
while(p_stLinkTable)
{
SCR_M_DyAr_DeleteElementWithMemLevel
(
SCR_tdst_Link_Value,
p_stLinkTable->stLinkArray,
{
if(_cMode_ == 0)
{
fn_v_Link_AssertValidP(p_stLinkTable, _p_stPointer_);
fn_v_Mem_SetMode(_p_stPointer_->stHeader.ucMemLevel);
SCR_M_Mem_Free(_p_stPointer_->p_szKey);
}
},
_ucMin,
_ucMax
);
SCR_M_Hash_DeleteWithMemLevel
(
p_stLinkTable->a_stHashTableForValues,
_ucMin,
_ucMax
);
SCR_M_Hash_DeleteWithMemLevel
(
p_stLinkTable->a_stHashTableForKeys,
_ucMin,
_ucMax
);
uiPosTables++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Table, uiPosTables, p_stLinkTable, SCR_g_st_Link_Array);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}

View File

@@ -0,0 +1,236 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Mem.c
* Managment of memory.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#define __DeclareGlobalVariableMmgScr_h__
#define __DeclareGlobalVariableErrScr_h__
#include "SCR.h"
#undef __DeclareGlobalVariableMmgScr_h__
#undef __DeclareGlobalVariableErrScr_h__
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
unsigned char g_uc_Mem_CurrentMemLevel;
unsigned char g_uc_Mem_CurrentLinkLevel;
unsigned char g_uc_Mem_CurrentAllocationType;
unsigned long g_a_ul_Mem_BlocAllocationSize[E_ucScrMaxBlocksNb];
unsigned long g_a_ul_Mem_MemoryAllocated[256];
unsigned char g_uc_Mem_LastMemLevel;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init of memory managment.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Mem_InitModule(void)
{
static char s_cFirstInit = 1;
/* Must init only one time error module (in case of multiple script init/close) */
if(s_cFirstInit == 1)
{
Erm_M_InitErrMsg(Scr);
s_cFirstInit = 0;
}
Mmg_M_InitMmg(Scr);
memset(&g_a_ul_Mem_BlocAllocationSize, 0, E_ucScrMaxBlocksNb * sizeof(unsigned long));
memset(&g_a_ul_Mem_MemoryAllocated, 0, E_ucScrMaxBlocksNb * sizeof(unsigned long));
g_uc_Mem_CurrentMemLevel = 0;
g_uc_Mem_CurrentLinkLevel = 0;
g_uc_Mem_LastMemLevel = 0;
g_uc_Mem_CurrentAllocationType = E_ucDynamic;
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Mem_CloseModule(void)
{
SCR_fn_v_Mem_DeleteWithMemLevel(0, 255);
memset(&g_a_ul_Mem_BlocAllocationSize, 0, E_ucScrMaxBlocksNb * sizeof(unsigned long));
memset(&g_a_ul_Mem_MemoryAllocated, 0, E_ucScrMaxBlocksNb * sizeof(unsigned long));
g_uc_Mem_CurrentMemLevel = 0;
g_uc_Mem_CurrentLinkLevel = 0;
g_uc_Mem_LastMemLevel = 0;
g_uc_Mem_CurrentAllocationType = E_ucDynamic;
Mmg_fn_v_StopMmg(Erm_M_ucGiveModuleId(Scr));
}
/*
*-------------------------------------------------------------------------------------------------
* Init of memory managment.
* Use of MMG and ERM modules.
* _p_ulMemorySize : Address of unsigned long size for blocs. Size if 0 for a dynamic malloc.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Mem_InitWithMemLevel(unsigned long *_p_ulMemorySize)
{
unsigned char ucIndex;
for(ucIndex = 0; ucIndex < E_ucScrMaxBlocksNb; ucIndex++)
{
if(g_a_ul_Mem_BlocAllocationSize[ucIndex] == 0)
{
g_a_ul_Mem_BlocAllocationSize[ucIndex] = *_p_ulMemorySize;
if(*_p_ulMemorySize)
{
Mmg_M_InitBlockV5_1_0(Scr, ucIndex, *_p_ulMemorySize,200000);
}
}
_p_ulMemorySize++;
}
}
/*
*-------------------------------------------------------------------------------------------------
* To reduce memory size.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Mem_ReduceMemory(void)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Anl_ReduceMemory();
fn_v_File_ReduceMemory();
fn_v_Link_ReduceMemory();
fn_v_Ntfy_ReduceMemory();
fn_v_Sect_ReduceMemory();
fn_v_Vars_ReduceMemory();
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To delete what correspond to a given priority.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_Mem_DeleteWithMemLevel(unsigned char _ucMin, unsigned char _ucMax)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
short wMemLevel;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Parse all levels.
* We finish with level 0 cause it's the level for basic scripts datas.
*/
for(wMemLevel = _ucMax; wMemLevel >= _ucMin; wMemLevel--)
{
fn_v_Anl_DeleteWithMemLevel(_ucMin, _ucMax);
fn_v_File_DeleteWithMemLevel(_ucMin, _ucMax);
fn_v_Link_DeleteWithMemLevel(_ucMin, _ucMax);
fn_v_Ntfy_DeleteWithMemLevel(_ucMin, _ucMax);
fn_v_Sect_DeleteWithMemLevel(_ucMin, _ucMax);
fn_v_Vars_DeleteWithMemLevel(_ucMin, _ucMax);
/* Delete static bloc */
if((unsigned char) wMemLevel < E_ucScrMaxBlocksNb)
{
if(g_a_ul_Mem_BlocAllocationSize[(unsigned char) wMemLevel])
{
Mmg_M_DeleteBlock(Scr, (unsigned char) wMemLevel);
g_a_ul_Mem_BlocAllocationSize[(unsigned char) wMemLevel] = 0;
}
}
}
SCR_fn_v_Mem_ReduceMemory();
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To get and set current memory level.
*-------------------------------------------------------------------------------------------------
*/
unsigned char SCR_fn_uc_Mem_GetCurrentLevel(void)
{
return g_uc_Mem_CurrentMemLevel;
}
void SCR_fn_v_Mem_SetCurrentLevel(unsigned char _ucLevel)
{
g_uc_Mem_CurrentMemLevel = _ucLevel;
}
unsigned char SCR_fn_uc_Mem_GetCurrentLinkLevel(void)
{
return g_uc_Mem_CurrentLinkLevel;
}
void SCR_fn_v_Mem_SetCurrentLinkLevel(unsigned char _ucLevel)
{
g_uc_Mem_CurrentLinkLevel = _ucLevel;
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Mem_SetMode(unsigned char _ucPrio)
{
g_uc_Mem_LastMemLevel = _ucPrio;
if
(
(_ucPrio >= E_ucScrMaxBlocksNb)
|| (g_a_ul_Mem_BlocAllocationSize[_ucPrio] == 0)
)
{
g_uc_Mem_CurrentAllocationType = E_ucDynamic;
}
else
{
g_uc_Mem_CurrentAllocationType = _ucPrio;
}
}
/*
*-------------------------------------------------------------------------------------------------
* Get the maximum allocation for a given memory level.
* _ucLevelMin : Min memory level to retreive
* _ucLevelMax : Max memory level to retreive
*-------------------------------------------------------------------------------------------------
*/
unsigned long SCR_fn_ul_Mem_GetAllocationSize(unsigned char _ucLevelMin, unsigned long _ucLevelMax)
{
int iIndex;
unsigned long ulTot = 0;
for(iIndex = (int) _ucLevelMin; iIndex <= (int) _ucLevelMax; iIndex++)
{
ulTot += g_a_ul_Mem_MemoryAllocated[(unsigned char) iIndex];
}
return ulTot;
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
#ifndef RETAIL
void Scr_PrintUsedStaticMemory(void)
{
Mmg_M_PrintUsedStaticMemoryInModule(Scr);
}
#endif /* RETAIL */

View File

@@ -0,0 +1,184 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Ntfy.c
* To manage notify orders.
*
* Scripts, Beaudet Christophe, (c) Ubi Simulations 1997
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* Dynamic array of all notify.
*/
SCR_tdst_DyAr_Description SCR_g_st_Ntfy_Array;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_InitModule(void)
{
fn_v_DyAr_InitArray(&SCR_g_st_Ntfy_Array);
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_CloseModule(void)
{
SCR_M_DyAr_DeleteAllElements(SCR_tdst_Ntfy_Description, &SCR_g_st_Ntfy_Array, ;);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To notify a modification to the script saver.
* _p_szSectionName : Section modify.
* _pfn_vCallback : Call back to call by the script saver.
* _p_vData : Data associated to the notification.
* _eAction : Real modification action.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_Add
(
char *_p_szSectionName,
SCR_tdpfn_Ntfy_Callback _pfn_vCallback,
void *_p_vData,
SCR_tde_Ntfy_Action _eAction
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
unsigned char ucMemo;
SCR_tdst_Ntfy_Description *p_stNotify;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szSectionName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Add element in array.
*/
ucMemo = g_uc_Mem_CurrentMemLevel;
g_uc_Mem_CurrentMemLevel = 0;
SCR_M_DyAr_AddElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
g_uc_Mem_CurrentMemLevel = ucMemo;
/*
* Initialize structure
*/
strcpy(p_stNotify->a_szSectionName, _p_szSectionName);
p_stNotify->pfn_vCallback = _pfn_vCallback;
p_stNotify->p_vData = _p_vData;
p_stNotify->eAction = _eAction;
}
/*
*-------------------------------------------------------------------------------------------------
* To delete a notification.
* _p_stNotify : Notification to delete.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_Delete(SCR_tdst_Ntfy_Description *_p_stNotify)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Ntfy_Description, _p_stNotify);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Delete structure.
*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Ntfy_Description,
_p_stNotify->stHeader.uiIndexInArray,
&SCR_g_st_Ntfy_Array,
;
);
}
/*
*-------------------------------------------------------------------------------------------------
* To search a notification.
* _p_szSectionName : Section name to search.
* Returns address of structure if found, else NULL.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Ntfy_Description *fnp_st_Ntfy_Search(char *_p_szSectionName)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_Ntfy_Description *p_stPointer = NULL;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szSectionName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Search notification and return pointer.
*/
SCR_M_DyAr_SearchElement
(
SCR_tdst_Ntfy_Description,
uiPos,
p_stPointer,
SCR_g_st_Ntfy_Array,
(!strcmpi(p_stPointer->a_szSectionName, _p_szSectionName))
);
return p_stPointer;
}
/*
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
*/
/*
*-------------------------------------------------------------------------------------------------
* To reduce memory size.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_ReduceMemory(void)
{
/* Pack array of open files */
SCR_M_DyAr_PackArray(SCR_tdst_Ntfy_Description, SCR_g_st_Ntfy_Array, ;);
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Ntfy_DeleteWithMemLevel(unsigned char _ucMin, unsigned char _ucMax)
{
SCR_M_DyAr_DeleteElementWithMemLevel
(
SCR_tdst_Ntfy_Description,
SCR_g_st_Ntfy_Array,
;,
_ucMin,
_ucMax
);
}

View File

@@ -0,0 +1,527 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Page.c
* Managment of pages for high level saving functions.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* To allocate and initialize a new page.
* Returns allocated structure.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Page_Description *fnp_st_Page_Allocate(void)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Mem_SetMode(0);
/*
* Allocate the page.
*/
SCR_M_Mem_Alloc(SCR_tdst_Page_Description, p_stPage, 1);
/*
* Initialize the page.
*/
SCR_M_Dbg_UpdateSizeOf_P(SCR_tdst_Page_Description, p_stPage);
p_stPage->iNumOfChars = 0;
p_stPage->p_stNext = p_stPage->p_stPrev = NULL;
SCR_M_Mem_Alloc(char, p_stPage->d_cBuffer, SCR_CV_ui_Cfg_SizePageBuf);
return p_stPage;
}
/*
*-------------------------------------------------------------------------------------------------
* To delete an existing page.
* Returns allocated structure.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_Free(SCR_tdst_Page_Description *_p_stPage)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Page_Description, _p_stPage);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Mem_SetMode(0);
SCR_M_Mem_Free(_p_stPage->d_cBuffer);
SCR_M_Mem_Free(_p_stPage);
}
/*
*-------------------------------------------------------------------------------------------------
* To delete all pages of a file.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_DeleteAll(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stPage, *p_stNext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_stPage = _p_stFile->d_stFirstPage;
while(p_stPage)
{
p_stNext = p_stPage->p_stNext;
fn_v_Page_Free(p_stPage);
p_stPage = p_stNext;
}
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Link a page after another one.
* _p_stFile : File concerned.
* _p_stPage : Page to link.
* _p_stRef : Reference page.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_LinkAfter
(
SCR_tdst_File_Description *_p_stFile,
SCR_tdst_Page_Description *_p_stPage,
SCR_tdst_Page_Description *_p_stRef
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Page_Description, _p_stPage);
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Page_Description, _p_stRef);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
_p_stPage->p_stNext = _p_stRef->p_stNext;
_p_stPage->p_stPrev = _p_stRef;
if(_p_stRef->p_stNext)
_p_stRef->p_stNext->p_stPrev = _p_stPage;
else
_p_stFile->d_stLastPage = _p_stPage;
_p_stRef->p_stNext = _p_stPage;
}
/*
*-------------------------------------------------------------------------------------------------
* To unlink a page from a list of page.
* _p_stFile : File concerned.
* _p_stPage : Page to unlink.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_Unlink
(
SCR_tdst_File_Description *_p_stFile,
SCR_tdst_Page_Description *_p_stPage
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Page_Description, _p_stPage);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(_p_stFile->d_stFirstPage == _p_stPage)
{
_p_stFile->d_stFirstPage = _p_stPage->p_stNext;
if(_p_stFile->d_stFirstPage == NULL)
_p_stFile->d_stFirstPage = _p_stPage->p_stPrev;
}
if(_p_stFile->d_stLastPage == _p_stPage)
{
_p_stFile->d_stLastPage = _p_stPage->p_stNext;
if(_p_stFile->d_stLastPage == NULL)
_p_stFile->d_stLastPage = _p_stPage->p_stPrev;
}
if(_p_stPage->p_stNext)
_p_stPage->p_stNext->p_stPrev = _p_stPage->p_stPrev;
if(_p_stPage->p_stPrev)
_p_stPage->p_stPrev->p_stNext = _p_stPage->p_stNext;
}
/*
*-------------------------------------------------------------------------------------------------
* Split a full page in 2 parts.
* _p_stFile : File concerned.
* _p_stPage : Page to split.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_Split
(
SCR_tdst_File_Description *_p_stFile,
SCR_tdst_Page_Description *_p_stPage
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stNewPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Page_Description, _p_stPage);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Allocate new page.
*/
p_stNewPage = fnp_st_Page_Allocate();
/*
* Copy second part of actual page to new one.
*/
memcpy
(
p_stNewPage->d_cBuffer,
&_p_stPage->d_cBuffer[SCR_CV_ui_Cfg_SizePageBuf2],
SCR_CV_ui_Cfg_SizePageBuf2
);
p_stNewPage->iNumOfChars = SCR_CV_ui_Cfg_SizePageBuf2;
_p_stPage->iNumOfChars -= SCR_CV_ui_Cfg_SizePageBuf2;
/*
* Update current position.
*/
if(_p_stFile->iCurPosInPage >= SCR_CV_ui_Cfg_SizePageBuf2)
{
_p_stFile->d_stCurPage = p_stNewPage;
_p_stFile->iCurPosInPage -= SCR_CV_ui_Cfg_SizePageBuf2;
}
/*
* Link new page after slitted one.
*/
fn_v_Page_LinkAfter(_p_stFile, p_stNewPage, _p_stPage);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Insert a character at current position.
* _p_stFile : File concerned.
* _cChar : Character to insert.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_InsertChar(SCR_tdst_File_Description *_p_stFile, char _cChar)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_stPage = _p_stFile->d_stCurPage;
/*
* Current page is full.
*/
if(p_stPage->iNumOfChars == SCR_CV_ui_Cfg_SizePageBuf)
{
fn_v_Page_Split(_p_stFile, p_stPage);
p_stPage = _p_stFile->d_stCurPage;
}
/*
* Shift buffer of page.
*/
memmove
(
&p_stPage->d_cBuffer[_p_stFile->iCurPosInPage + 1],
&p_stPage->d_cBuffer[_p_stFile->iCurPosInPage],
p_stPage->iNumOfChars - _p_stFile->iCurPosInPage
);
/*
* Set character.
*/
p_stPage->d_cBuffer[_p_stFile->iCurPosInPage] = _cChar;
p_stPage->iNumOfChars++;
/*
* Increment current position.
*/
fn_v_Page_ToNextChar(_p_stFile);
}
/*
*-------------------------------------------------------------------------------------------------
* Delete character at current position.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_DeleteChar(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_Assert_P(_p_stFile->d_stCurPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* EOF ? */
p_stPage = _p_stFile->d_stCurPage;
if(p_stPage->d_cBuffer[_p_stFile->iCurPosInPage] == 0)
return;
/*
* We vill delete page ?.
*/
if(p_stPage->iNumOfChars == 1)
{
SCR_M_Dbg_Assert_P(p_stPage->p_stNext);
_p_stFile->d_stCurPage = p_stPage->p_stNext;
_p_stFile->iCurPosInPage = 0;
fn_v_Page_Unlink(_p_stFile, p_stPage);
fn_v_Page_Free(p_stPage);
}
else
{
/*
* We delete the last character of page.
* We compute the next current position.
*/
if(_p_stFile->iCurPosInPage == (p_stPage->iNumOfChars - 1))
{
SCR_M_Dbg_Assert_P(p_stPage->p_stNext != NULL);
_p_stFile->d_stCurPage = p_stPage->p_stNext;
_p_stFile->iCurPosInPage = 0;
p_stPage->iNumOfChars--;
}
/*
* Else we shift the buffer normally.
*/
else
{
memmove
(
&p_stPage->d_cBuffer[_p_stFile->iCurPosInPage],
&p_stPage->d_cBuffer[_p_stFile->iCurPosInPage + 1],
p_stPage->iNumOfChars - _p_stFile->iCurPosInPage - 1
);
p_stPage->iNumOfChars--;
}
}
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Go to next position.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_ToNextChar(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_Assert_P(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(_p_stFile->iCurPosInPage + 1 == _p_stFile->d_stCurPage->iNumOfChars)
{
if(_p_stFile->d_stCurPage->p_stNext)
{
_p_stFile->iCurPosInPage = 0;
_p_stFile->d_stCurPage = _p_stFile->d_stCurPage->p_stNext;
}
}
else
_p_stFile->iCurPosInPage++;
}
/*
*-------------------------------------------------------------------------------------------------
* Go to previous position.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_ToPrevChar(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_Assert_P(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(_p_stFile->iCurPosInPage == 0)
{
if(_p_stFile->d_stCurPage->p_stPrev)
{
_p_stFile->d_stCurPage = _p_stFile->d_stCurPage->p_stPrev;
_p_stFile->iCurPosInPage = _p_stFile->d_stCurPage->iNumOfChars - 1;
}
}
else
_p_stFile->iCurPosInPage--;
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* Load a complete file in memory.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_LoadFile(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
size_t xRead;
SCR_tdst_Page_Description *p_stPage;
int iRes;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Create first page.
*/
_p_stFile->d_stFirstPage = fnp_st_Page_Allocate();
_p_stFile->d_stLastPage = _p_stFile->d_stCurPage = _p_stFile->d_stFirstPage;
_p_stFile->iCurPosInPage = 0;
SCR_M_fseek(_p_stFile, 0, SEEK_SET, iRes);
if(iRes)
{
SCR_M_Err_UpdateSyntaxError();
sprintf
(
g_st_Err_GlobalError.a_szBufferTmp2,
"File is \"%s\".",
_p_stFile->a_szFileName
);
SCR_M_Err_RaiseError(SCR_EI_Err_ReadFile);
}
/*
* Read file.
*/
while(!SCR_M_feof(_p_stFile))
{
/* Read one page from file */
xRead = SCR_M_fread
(
_p_stFile->d_stLastPage->d_cBuffer,
sizeof(char),
SCR_CV_ui_Cfg_SizePageBuf2,
_p_stFile
);
_p_stFile->d_stLastPage->iNumOfChars = xRead;
/* Allocate a new page if this one is full */
if((xRead == SCR_CV_ui_Cfg_SizePageBuf2) && (!SCR_M_feof(_p_stFile)))
{
p_stPage = fnp_st_Page_Allocate();
fn_v_Page_LinkAfter(_p_stFile, p_stPage, _p_stFile->d_stLastPage);
}
}
/*
* Add an '\n' and an EOF character at the end of the file.
*/
if(_p_stFile->d_stLastPage->d_cBuffer[_p_stFile->d_stLastPage->iNumOfChars - 1] != '\n')
{
_p_stFile->d_stLastPage->d_cBuffer[_p_stFile->d_stLastPage->iNumOfChars ] = '\n';
_p_stFile->d_stLastPage->iNumOfChars++;
}
_p_stFile->d_stLastPage->d_cBuffer[_p_stFile->d_stLastPage->iNumOfChars] = '\0';
_p_stFile->d_stLastPage->iNumOfChars++;
}
/*
*-------------------------------------------------------------------------------------------------
* Save a complete memory file.
* _p_stFile : File concerned.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_SaveFile(SCR_tdst_File_Description *_p_stFile)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Page_Description *p_stPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_Assert_P(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_stPage = _p_stFile->d_stFirstPage;
while(p_stPage)
{
if(p_stPage == _p_stFile->d_stLastPage) /* Cause of EOF */
p_stPage->iNumOfChars--;
SCR_M_fwrite(p_stPage->d_cBuffer, sizeof(char), p_stPage->iNumOfChars, _p_stFile);
p_stPage = p_stPage->p_stNext;
}
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To seek to a specific position.
* _p_stFile : File concerned.
* lOffset : Offset to seek.
* iOrigin : Origin to seek from.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Page_Seek(SCR_tdst_File_Description *_p_stFile, long lOffset, int iOrigin)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lCount;
SCR_tdst_Page_Description *p_stPage;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_stFile != NULL);
SCR_M_Dbg_Assert_P(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Place current position from the end of file.
*/
if(iOrigin == SEEK_END)
{
p_stPage = _p_stFile->d_stLastPage;
lCount = p_stPage->iNumOfChars;
while(lCount <= lOffset)
{
p_stPage = p_stPage->p_stPrev;
lCount += p_stPage->iNumOfChars;
}
_p_stFile->d_stCurPage = p_stPage;
_p_stFile->iCurPosInPage = lCount - lOffset - 1;
}
/*
* Place current position from the beginning of file.
*/
else
{
SCR_M_Dbg_Assert_P(iOrigin == SEEK_SET);
p_stPage = _p_stFile->d_stFirstPage;
lCount = p_stPage->iNumOfChars;
while((lCount <= lOffset) && (p_stPage->p_stNext))
{
p_stPage = p_stPage->p_stNext;
lCount += p_stPage->iNumOfChars;
}
_p_stFile->d_stCurPage = p_stPage;
_p_stFile->iCurPosInPage = p_stPage->iNumOfChars - (lCount - lOffset);
if((p_stPage->p_stNext == NULL) && (lCount <= lOffset))
_p_stFile->iCurPosInPage = p_stPage->iNumOfChars - 1;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,287 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Sect.c
* Managment of open sections.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* Array of all open sections.
* Hadh table for that array.
*/
SCR_tdst_DyAr_Description SCR_g_st_Sect_ArrayOpen;
SCR_tda_st_Hash_Table SCR_g_a_st_Sect_HashTableOpen;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_InitModule(void)
{
fn_v_DyAr_InitArray(&SCR_g_st_Sect_ArrayOpen);
fn_v_Hash_InitTable(SCR_g_a_st_Sect_HashTableOpen);
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_CloseModule(void)
{
SCR_M_DyAr_DeleteAllElements(SCR_tdst_Sect_Open, &SCR_g_st_Sect_ArrayOpen, ;);
fn_v_Hash_CloseTable(SCR_g_a_st_Sect_HashTableOpen);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To add one open section. The section description must be in current context.
* _p_stContext : Current context.
* _xHashKey : Hash key code of section.
* Returns allocated structure.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Sect_Open *fnp_st_Sect_AddOpen
(
SCR_tdst_Cxt_Description *_p_stContext,
SCR_tdx_Hash_Key _xHashKey
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiSectionPos;
SCR_tdst_Sect_Open *p_stSection;
unsigned int uiIndexOfHashValue;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Cxt_Description, _p_stContext);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Add element in array.
* Add pointer in corresponding hash table.
*/
SCR_M_DyAr_AddElement(SCR_tdst_Sect_Open, uiSectionPos, p_stSection, SCR_g_st_Sect_ArrayOpen);
fnp_st_Hash_AddValue
(
_xHashKey,
SCR_g_a_st_Sect_HashTableOpen,
(unsigned long) p_stSection,
&uiIndexOfHashValue
);
/*
* Initialize structure.
*/
SCR_M_Cxt_CopyBuffers(&p_stSection->stBuffers, &_p_stContext->stBuffers);
memset(&p_stSection->stSectionValues, 0, sizeof(SCR_tdst_Cxt_Values));
p_stSection->uiLineInFile = _p_stContext->stPosition.uiLineInFile;
p_stSection->xHashKey = _xHashKey;
p_stSection->uiIndexOfHashValue = uiIndexOfHashValue;
/*
* Return structure.
*/
return p_stSection;
}
/*
*-------------------------------------------------------------------------------------------------
* Search for _p_stSection in all open files to set to NULL the p_stOpenSection field of section
* description.
* _p_stSection : Section to delete.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_UpdateSectionDes(SCR_tdst_Sect_Open *_p_stSection)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_File_Open *p_stOpenFile = NULL;
SCR_tdst_Anl_SectionDes *p_stSectionDes = NULL;
unsigned int ui_Num = 0;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Parse all files to get section des.
*/
uiPos = 0;
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Open, uiPos, p_stOpenFile, SCR_g_st_File_ArrayOpen);
while(p_stOpenFile)
{
p_stSectionDes = fnp_st_Anl_SearchSectionDes(p_stOpenFile, _p_stSection->stBuffers.a_szBufferCompleteName, 0,ui_Num);
while(p_stSectionDes)
{
p_stSectionDes->p_stOpenSection = NULL;
ui_Num++;
p_stSectionDes = fnp_st_Anl_SearchSectionDes(p_stOpenFile, _p_stSection->stBuffers.a_szBufferCompleteName, 0,ui_Num);
}
/* if(p_stSectionDes)
p_stSectionDes->p_stOpenSection = NULL;*/
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Open, uiPos, p_stOpenFile, SCR_g_st_File_ArrayOpen);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}
/*
*-------------------------------------------------------------------------------------------------
* To delete an already open section.
* _p_stSection : Section to delete.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_DeleteOpen(SCR_tdst_Sect_Open *_p_stSection)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Sect_Open, _p_stSection);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_Sect_UpdateSectionDes(_p_stSection);
/*
* Delete element in hash table.
*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Hash_Value,
_p_stSection->uiIndexOfHashValue,
&SCR_g_a_st_Sect_HashTableOpen[_p_stSection->xHashKey],
;
);
/*
* Delete structure.
*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Sect_Open,
_p_stSection->stHeader.uiIndexInArray,
&SCR_g_st_Sect_ArrayOpen,
;
);
}
/*
*-------------------------------------------------------------------------------------------------
* To search an open section.
* _p_szSectionName : Complete section name.
* _uiLineInFile : Line of section in file (0 to ignore).
* _xHashKey : Hash key code of section.
* Returns structure found, NULL if not.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Sect_Open *fnp_st_Sect_SearchOpen
(
char *_p_szSectionName,
unsigned int _uiLineInFile,
SCR_tdx_Hash_Key _xHashKey
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiValuePos;
SCR_tdst_Hash_Value *p_stValue = NULL;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szSectionName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Search section.
*/
SCR_M_DyAr_SearchElement
(
SCR_tdst_Hash_Value,
uiValuePos,
p_stValue,
SCR_g_a_st_Sect_HashTableOpen[_xHashKey],
(
(!strcmpi
(
((SCR_tdst_Sect_Open *) (p_stValue->ulValue))->stBuffers.a_szBufferCompleteName,
_p_szSectionName
)
)
&& (
(_uiLineInFile == 0)
|| (((SCR_tdst_Sect_Open *) (p_stValue->ulValue))->uiLineInFile == _uiLineInFile)
)
)
);
/*
* Return address of structure.
*/
if(p_stValue)
return (SCR_tdst_Sect_Open *) p_stValue->ulValue;
else
return NULL;
}
/*
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
*/
/*
*-------------------------------------------------------------------------------------------------
* To reduce memory size.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_ReduceMemory(void)
{
/* Pack array of open sections */
SCR_M_DyAr_PackArray(SCR_tdst_Sect_Open, SCR_g_st_Sect_ArrayOpen, ;);
/* Pack open section hash table */
SCR_M_Hash_PackArray(SCR_g_a_st_Sect_HashTableOpen, SCR_tdst_Sect_Open, SCR_g_st_Sect_ArrayOpen, xHashKey, uiIndexOfHashValue);
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Sect_DeleteWithMemLevel(unsigned char _ucMin, unsigned char _ucMax)
{
SCR_M_DyAr_DeleteElementWithMemLevel
(
SCR_tdst_Sect_Open,
SCR_g_st_Sect_ArrayOpen,
{
fn_v_Sect_UpdateSectionDes(_p_stPointer_);
},
_ucMin,
_ucMax
);
SCR_M_Hash_DeleteWithMemLevel
(
SCR_g_a_st_Sect_HashTableOpen,
_ucMin,
_ucMax
);
}

View File

@@ -0,0 +1,470 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Save.c
* Functions for saving, level 0.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <direct.h>
#include <io.h>
#include <stdarg.h>
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* To save current indentation for save functions.
*/
unsigned int SCR_g_ui_SvL0_IndentationLevel = 0;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* To write a character to a file.
* _p_stFile : File to write character.
* _cChar : Character to write.
* Returns character read.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_SvL0_fputc(SCR_tdst_File_Description *_p_stFile, char _cChar)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int iRes;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(_p_stFile->d_stFirstPage == NULL)
{
if(_cChar == '\n')
{
SCR_M_fputc('\r', _p_stFile, iRes);
if(iRes == EOF)
{
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", _p_stFile->a_szFileName);
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
SCR_M_Err_RaiseError(SCR_EI_Err_WriteFile);
}
}
SCR_M_fputc(_cChar, _p_stFile, iRes);
if(iRes == EOF)
{
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", _p_stFile->a_szFileName);
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
SCR_M_Err_RaiseError(SCR_EI_Err_WriteFile);
}
}
else
{
if(_cChar == '\n')
fn_v_Page_InsertChar(_p_stFile, '\r');
fn_v_Page_InsertChar(_p_stFile, _cChar);
}
}
/*
*-------------------------------------------------------------------------------------------------
* To write a string to a file.
* _p_stFile : File to write string.
* _p_szString : String to write.
* Returns character read.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_SvL0_fputs(SCR_tdst_File_Description *_p_stFile, char *_p_szString)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
while(*_p_szString)
fn_v_SvL0_fputc(_p_stFile, *_p_szString++);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To save a line in a script file with a list of string parameters.
* _p_stFile : File to save.
* _uiNumPars : Number of parameters.
* _ap_szParams : Array of parameters.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_SvL0_SaveNormalFormat
(
SCR_tdst_File_Description *_p_stFile,
unsigned int _uiNumPars,
char *_ap_szParams[]
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char cAddDel;
unsigned int uiIndex;
char *p_szTemp;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
SCR_M_Dbg_Assert_D(_uiNumPars != 0);
SCR_M_Dbg_Assert_D(_ap_szParams != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
cAddDel = 0;
for(uiIndex = 0; uiIndex < _uiNumPars; uiIndex++)
{
/*
* Add " if there is a space character in parameter ?
*/
if(_ap_szParams[uiIndex][0] != '\"')
{
p_szTemp = _ap_szParams[uiIndex];
if(*p_szTemp != SCR_CC_c_Cfg_VarMark)
{
while(*p_szTemp)
{
if(!gs_a256_cIsCharValidForWord[*p_szTemp])
{
cAddDel = 1;
break;
}
p_szTemp++;
}
}
}
/*
* Parameter.
*/
if(cAddDel)
fn_v_SvL0_fputc(_p_stFile, '"');
fn_v_SvL0_fputs(_p_stFile, _ap_szParams[uiIndex]);
if(cAddDel)
fn_v_SvL0_fputc(_p_stFile, '"');
cAddDel = 0;
/* Write parameter separator */
if(uiIndex < (_uiNumPars - 1))
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_ParamSeparator);
}
}
/*
*-------------------------------------------------------------------------------------------------
* To save a line in a script file with an array of parameters.
* _p_stFile : File to save.
* _eFormat : Format of parameters.
* _ap_szParams : Array of parameters.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_SvL0_SaveArrayFormat
(
SCR_tdst_File_Description *_p_stFile,
SCR_tde_SvL0_Format _eFormat,
char *_ap_szParams[]
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long ulIndex, ulEnd;
char *p_szData, *p_szString;
char a_szBuffer[SCR_CV_ui_Cfg_MaxLenLine];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
SCR_M_Dbg_Assert_D(_ap_szParams != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Get number of values in array at index 0 */
ulEnd = (long) _ap_szParams[0];
/* Get first value at index 1 */
p_szData = _ap_szParams[1];
/* Save all entries of array */
for(ulIndex = 0; ulIndex < ulEnd; ulIndex++)
{
switch(_eFormat)
{
case SCR_EF_SvL0_ArrayByte:
sprintf(a_szBuffer, "%d", p_szData[ulIndex]);
break;
case SCR_EF_SvL0_ArrayShort:
sprintf(a_szBuffer, "%d", ((short *) p_szData)[ulIndex]);
break;
case SCR_EF_SvL0_ArrayLong:
sprintf(a_szBuffer, "%ld", ((long *) p_szData)[ulIndex]);
break;
case SCR_EF_SvL0_ArrayFloat:
sprintf(a_szBuffer, "%f", ((float *) p_szData)[ulIndex]);
break;
case SCR_EF_SvL0_ArrayDouble:
sprintf(a_szBuffer, "%lf", ((double *) p_szData)[ulIndex]);
break;
case SCR_EF_SvL0_ArrayInt:
sprintf(a_szBuffer, "%d", ((int *) p_szData)[ulIndex]);
break;
case SCR_EF_SvL0_ArrayBoolean:
if(p_szData[ulIndex] == 0)
p_szString = "False";
else
p_szString = "True";
sprintf(a_szBuffer, "%s", p_szString);
break;
case SCR_EF_SvL0_ArrayDisEna:
if(p_szData[ulIndex] == 0)
p_szString = "Disable";
else
p_szString = "Enable";
sprintf(a_szBuffer, "%s", p_szString);
break;
}
/* Write formatted string */
fn_v_SvL0_fputs(_p_stFile, a_szBuffer);
/* Write parameter separator */
if(ulIndex < (ulEnd - 1))
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_ParamSeparator);
}
}
/*
*=================================================================================================
*
* PUBLIC
*
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* To save the first word of a line.
* _p_stFile : File to save.
* _cFirstChar : The character to save before the line (can be '\0' to ignore).
* _p_szWord : Word to save (can be NULL to ignore).
* _cLastChar : Character to write after the word (can be '\0' to ignore).
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_SvL0_SaveWord
(
SCR_tdst_File_Description *_p_stFile,
char _cFirstChar,
char *_p_szWord,
char _cLastChar
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* _cFirstChar */
if(_cFirstChar != '\0')
fn_v_SvL0_fputc(_p_stFile, _cFirstChar);
/* Word */
if(_p_szWord)
fn_v_SvL0_fputs(_p_stFile, _p_szWord);
/* _cLastChar */
if(_cLastChar != '\0')
fn_v_SvL0_fputc(_p_stFile, _cLastChar);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To save a format specifier.
* _p_stFile : File to save.
* _eFormat : Format of parameters.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_SvL0_SaveFormat
(
SCR_tdst_File_Description *_p_stFile,
SCR_tde_SvL0_Format _eFormat
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(_eFormat == SCR_EF_SvL0_Normal)
SCR_RETURN(;);
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_FormatBegMark);
switch(_eFormat)
{
case SCR_EF_SvL0_ArrayByte:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayByte);
break;
case SCR_EF_SvL0_ArrayShort:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayShort);
break;
case SCR_EF_SvL0_ArrayLong:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayLong);
break;
case SCR_EF_SvL0_ArrayFloat:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayFloat);
break;
case SCR_EF_SvL0_ArrayDouble:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayDouble);
break;
case SCR_EF_SvL0_ArrayInt:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayInt);
break;
case SCR_EF_SvL0_ArrayBoolean:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayBoolean);
break;
case SCR_EF_SvL0_ArrayDisEna:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayDisEna);
break;
case SCR_EF_SvL0_ArrayReferences:
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArray);
fn_v_SvL0_fputc(_p_stFile, SCR_CF_c_Cfg_FormatArrayReferences);
break;
}
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_FormatEndMark);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To save parameters with an array of parameters.
* _p_stFile : File to save.
* _eFormat : Format of parameters.
* _uiNumParams : Number of parameters in array.
* _ap_szParams : Array of parameters.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_SvL0_SaveParameters_AP
(
SCR_tdst_File_Description *_p_stFile,
SCR_tde_SvL0_Format _eFormat,
unsigned int _uiNumParams,
char *_ap_szParams[]
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
SCR_M_Dbg_Assert_D(_uiNumParams != 0);
SCR_M_Dbg_Assert_D(_ap_szParams != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_ParamBegMark);
if(_eFormat == SCR_EF_SvL0_Normal)
fn_v_SvL0_SaveNormalFormat(_p_stFile, _uiNumParams, _ap_szParams);
else
fn_v_SvL0_SaveArrayFormat(_p_stFile, _eFormat, _ap_szParams);
fn_v_SvL0_fputc(_p_stFile, SCR_CC_c_Cfg_ParamEndMark);
fn_v_SvL0_fputc(_p_stFile, '\n');
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
/*
*-------------------------------------------------------------------------------------------------
* To save a line in a script file with multi parameters on line.
* _p_stFile : File to save.
* _eFormat : Format of parameters.
* _uiNumPars : Number of optionnal parameters.
* ... : All parameters.
*-------------------------------------------------------------------------------------------------
*/
void SCR_fn_v_SvL0_SaveParameters_MP
(
SCR_tdst_File_Description *_p_stFile,
SCR_tde_SvL0_Format _eFormat,
unsigned int _uiNumPars,
...
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_list xArgList;
char a_szBuffer[SCR_CV_ui_Cfg_MaxLenLine];
char *ap_szParams[SCR_CV_ui_Cfg_MaxNumPars];
char *p_szFormat, *p_szSearch;
unsigned int uiIndex;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_D(_p_stFile != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(xArgList, _uiNumPars);
/*
* Format = scanf ?
* First parameter must be string format.
* Convert all other parameters.
*/
uiIndex = 0;
if(_eFormat == SCR_EF_SvL0_Scanf)
{
p_szFormat = va_arg(xArgList, char *);
SCR_M_Dbg_Verify_D(vsprintf(a_szBuffer, p_szFormat, xArgList) >= 0);
/*
* Convert a_szBuffer to an array of pointers to parameters.
* First parameter is scanf format.
*/
p_szFormat = a_szBuffer;
_uiNumPars = 1;
do
{
ap_szParams[uiIndex++] = p_szFormat;
p_szSearch = strchr(p_szFormat, SCR_CF_c_Cfg_ScanfSeparator);
if(p_szSearch)
{
*p_szSearch = '\0';
p_szFormat = p_szSearch + 1;
_uiNumPars++;
}
} while(p_szSearch);
ap_szParams[uiIndex] = NULL;
_eFormat = SCR_EF_SvL0_Normal;
}
/*
* Else we construct an array of parameters with list.
*/
else
{
for(uiIndex = 0; uiIndex < _uiNumPars; uiIndex++)
ap_szParams[uiIndex] = va_arg(xArgList, char *);
}
/*
* Save parameters.
*/
SCR_fn_v_SvL0_SaveParameters_AP
(
_p_stFile,
_eFormat,
_uiNumPars,
ap_szParams
);
va_end(xArgList);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,179 @@
/*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* SCR_Vars.c
* To manage global script variables.
*
* Scripts, Beaudet Christophe
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*
*=================================================================================================
* Includes.
*=================================================================================================
*/
#include <memory.h>
#include "SCR.h"
/*
*=================================================================================================
* Global variables.
*=================================================================================================
*/
/*
* Array of all variables.
*/
SCR_tdst_DyAr_Description SCR_g_st_Vars_Array;
/*
*=================================================================================================
* Functions.
*=================================================================================================
*/
/*
*-------------------------------------------------------------------------------------------------
* Init.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Vars_InitModule(void)
{
fn_v_DyAr_InitArray(&SCR_g_st_Vars_Array);
}
/*
*-------------------------------------------------------------------------------------------------
* Close.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Vars_CloseModule(void)
{
SCR_M_DyAr_DeleteAllElements(SCR_tdst_Vars_Description, &SCR_g_st_Vars_Array, ;);
}
/*===============================================================================================*/
/*
*-------------------------------------------------------------------------------------------------
* To add one variable.
* _p_szName : Name of variable to add.
* _p_szValue : Value of variable to add.
* Returns allocated structure.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Vars_Description *fnp_st_Vars_Add
(
char *_p_szName,
char *_p_szValue
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_Vars_Description *p_stPointer;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szName != NULL);
SCR_M_Dbg_Assert_P(_p_szValue != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Add element in array.
*/
SCR_M_DyAr_AddElement(SCR_tdst_Vars_Description, uiPos, p_stPointer, SCR_g_st_Vars_Array);
/*
* Initialize structure.
*/
p_stPointer->stHeader.uiIndexInArray = uiPos;
strcpy(p_stPointer->a_szVarName, _p_szName);
strcpy(p_stPointer->a_szVarValue, _p_szValue);
/*
* Return structure.
*/
return p_stPointer;
}
/*
*-------------------------------------------------------------------------------------------------
* To delete a variable.
* _p_stVar : Variable to delete.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Vars_Delete(SCR_tdst_Vars_Description *_p_stVar)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Vars_Description, _p_stVar);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_DyAr_DeleteElement
(
SCR_tdst_Vars_Description,
_p_stVar->stHeader.uiIndexInArray,
&SCR_g_st_Vars_Array,
;);
}
/*
*-------------------------------------------------------------------------------------------------
* To search a variable.
* _p_szName : Name of variable to search.
* Returns structure found, NULL if not.
*-------------------------------------------------------------------------------------------------
*/
SCR_tdst_Vars_Description *fnp_st_Vars_Search(char *_p_szName)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int uiPos;
SCR_tdst_Vars_Description *p_stPointer = NULL;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_M_Dbg_Assert_P(_p_szName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Search variable and return pointer.
*/
SCR_M_DyAr_SearchElement
(
SCR_tdst_Vars_Description,
uiPos,
p_stPointer,
SCR_g_st_Vars_Array,
(!strcmpi(p_stPointer->a_szVarName, _p_szName))
);
return p_stPointer;
}
/*
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
**************************************************************************************************
*/
/*
*-------------------------------------------------------------------------------------------------
* To reduce memory size.
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Vars_ReduceMemory(void)
{
SCR_M_DyAr_PackArray(SCR_tdst_Vars_Description, SCR_g_st_Vars_Array, ;);
}
/*
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
*/
void fn_v_Vars_DeleteWithMemLevel(unsigned char _ucMin, unsigned char _ucMax)
{
SCR_M_DyAr_DeleteElementWithMemLevel
(
SCR_tdst_Vars_Description,
SCR_g_st_Vars_Array,
;,
_ucMin,
_ucMax
);
}

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[SCR.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project