Normalize all the line endings
This commit is contained in:
244
.cproject
244
.cproject
@@ -1,123 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="stubser" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cygwin.exe.debug" preannouncebuildStep="Git version header" prebuildStep="../resources/version.sh -d">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug.1911704982" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug.417099056" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"/>
|
||||
<builder buildPath="${workspace_loc:/stubi}/Debug" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug.1341361607" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug.518707357" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1228923598" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.698019963" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug.1903523299" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug">
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level.1935693909" name="Optimization Level" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level.967738241" name="Debug Level" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.75372444" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level.1758127696" name="Optimization Level" superClass="gnu.c.compiler.cygwin.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.cygwin.exe.debug.option.debugging.level.196472971" name="Debug Level" superClass="gnu.c.compiler.cygwin.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1914441723" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/ext}""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2046516674" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_DEBUG_OUTPUT=1"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1850965" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug.1913673353" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.994259447" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug.794081126" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233" name="Release" optionalBuildProperties="" parent="cdt.managedbuild.config.gnu.cygwin.exe.release" postannouncebuildStep="-- Copy release to bin folder --" postbuildStep="cp -f stubser.exe c:\cygwin\bin" preannouncebuildStep="Git version header" prebuildStep="../resources/version.sh">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release.213504424" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release.1771726366" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"/>
|
||||
<builder buildPath="${workspace_loc:/stubi}/Release" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release.1401457693" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.release"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release.414454857" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1199022435" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.237095479" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release.1684919419" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release">
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level.1663626866" name="Optimization Level" superClass="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level.1650973862" name="Debug Level" superClass="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1463094971" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.cygwin.exe.release.option.optimization.level.1258615624" name="Optimization Level" superClass="gnu.c.compiler.cygwin.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.cygwin.exe.release.option.debugging.level.929161689" name="Debug Level" superClass="gnu.c.compiler.cygwin.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.816204774" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/ext}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.257656751" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release.1085070010" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.746881963" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release.656504450" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="stubi.cdt.managedbuild.target.gnu.cygwin.exe.207306528" name="Executable" projectType="cdt.managedbuild.target.gnu.cygwin.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978;cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.75372444;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1850965">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233;cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1463094971;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.257656751">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="stubser" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cygwin.exe.debug" preannouncebuildStep="Git version header" prebuildStep="../resources/version.sh -d">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug.1911704982" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug.417099056" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"/>
|
||||
<builder buildPath="${workspace_loc:/stubi}/Debug" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug.1341361607" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug.518707357" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1228923598" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.698019963" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug.1903523299" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug">
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level.1935693909" name="Optimization Level" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level.967738241" name="Debug Level" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.75372444" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level.1758127696" name="Optimization Level" superClass="gnu.c.compiler.cygwin.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.cygwin.exe.debug.option.debugging.level.196472971" name="Debug Level" superClass="gnu.c.compiler.cygwin.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1914441723" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/ext}""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2046516674" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_DEBUG_OUTPUT=1"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1850965" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug.1913673353" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.994259447" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug.794081126" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233" name="Release" optionalBuildProperties="" parent="cdt.managedbuild.config.gnu.cygwin.exe.release" postannouncebuildStep="-- Copy release to bin folder --" postbuildStep="cp -f stubser.exe c:\cygwin\bin" preannouncebuildStep="Git version header" prebuildStep="../resources/version.sh">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release.213504424" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release.1771726366" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"/>
|
||||
<builder buildPath="${workspace_loc:/stubi}/Release" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release.1401457693" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.release"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release.414454857" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1199022435" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.237095479" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release.1684919419" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release">
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level.1663626866" name="Optimization Level" superClass="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level.1650973862" name="Debug Level" superClass="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1463094971" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.cygwin.exe.release.option.optimization.level.1258615624" name="Optimization Level" superClass="gnu.c.compiler.cygwin.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.cygwin.exe.release.option.debugging.level.929161689" name="Debug Level" superClass="gnu.c.compiler.cygwin.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.816204774" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/ext}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.257656751" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release.1085070010" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.746881963" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release.656504450" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="stubi.cdt.managedbuild.target.gnu.cygwin.exe.207306528" name="Executable" projectType="cdt.managedbuild.target.gnu.cygwin.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978;cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.75372444;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1850965">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233;cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1463094971;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.257656751">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
52
.project
52
.project
@@ -1,26 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>stubser</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>stubser</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
@@ -1,11 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/delimiter=;
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/operation=replace
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/value=C\:\\cygwin
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/append=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/appendContributed=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/delimiter=;
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/operation=replace
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/value=C\:\\cygwin
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/append=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/appendContributed=true
|
||||
eclipse.preferences.version=1
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/delimiter=;
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/operation=replace
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/CYGWIN_HOME/value=C\:\\cygwin
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/append=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.debug.384908978/appendContributed=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/delimiter=;
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/operation=replace
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/CYGWIN_HOME/value=C\:\\cygwin
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/append=true
|
||||
environment/project/cdt.managedbuild.config.gnu.cygwin.exe.release.1204024233/appendContributed=true
|
||||
|
176
src/ext/debug.h
176
src/ext/debug.h
@@ -1,88 +1,88 @@
|
||||
/*!
|
||||
* @file debug.h
|
||||
* @brief Helper for debug output
|
||||
*
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: mst\n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.06.2016
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef _DEBUG_H_INCLUDED
|
||||
#define _DEBUG_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define isDebugLevel(dflag) (_DEBUG_OUTPUT >= dflag)
|
||||
|
||||
/*!
|
||||
* @brief extract only filename from __FILE__ without base path
|
||||
*/
|
||||
#define _DEBUG_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
|
||||
/*!
|
||||
* @brief Debug assert helper macro
|
||||
* @param cond condition for output
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* Condition as string is appended to the output.\n
|
||||
* e.g. DEBUG_LOG_ASSERT(i >= 1, DEBUG_LEVEL_INFO, "Not allowed");\n
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG_ASSERT(cond, dflag, format, args...) do { if(isDebugLevel(dflag) && (cond)) \
|
||||
printf("%s:%d:%s():(" #cond "): " format, \
|
||||
_DEBUG_FILENAME, __LINE__, __func__, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG_ASSERT(cond, dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Debug output helper macro
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG(dflag, format, args...) do { if(isDebugLevel(dflag)) \
|
||||
printf("%s:%d:%s(): " format, \
|
||||
_DEBUG_FILENAME, __LINE__, __func__, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG(dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Debug output helper macro to append text without addition information
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG_APPEND(dflag, format, args...) do { if(isDebugLevel(dflag)) \
|
||||
printf(format, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG_APPEND(dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
typedef enum _EDEBUGLEVEL
|
||||
{
|
||||
DEBUG_LEVEL_ALWAYS = 0, /* DEBUG_LOGs are visible regardless of DEBUG_LEVEL */
|
||||
DEBUG_LEVEL_INFO = 1, /* Visible when application started with -v */
|
||||
DEBUG_LEVEL_WARNING = 2, /* Visible when application started with -vv */
|
||||
DEBUG_LEVEL_ERROR = 3,
|
||||
/* Visible when application started with -vvv */
|
||||
} eDebugLevel;
|
||||
|
||||
#endif /* #ifndef _DEBUG_H_INCLUDED */
|
||||
/*!
|
||||
* @file debug.h
|
||||
* @brief Helper for debug output
|
||||
*
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: mst\n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.06.2016
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef _DEBUG_H_INCLUDED
|
||||
#define _DEBUG_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define isDebugLevel(dflag) (_DEBUG_OUTPUT >= dflag)
|
||||
|
||||
/*!
|
||||
* @brief extract only filename from __FILE__ without base path
|
||||
*/
|
||||
#define _DEBUG_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
|
||||
/*!
|
||||
* @brief Debug assert helper macro
|
||||
* @param cond condition for output
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* Condition as string is appended to the output.\n
|
||||
* e.g. DEBUG_LOG_ASSERT(i >= 1, DEBUG_LEVEL_INFO, "Not allowed");\n
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG_ASSERT(cond, dflag, format, args...) do { if(isDebugLevel(dflag) && (cond)) \
|
||||
printf("%s:%d:%s():(" #cond "): " format, \
|
||||
_DEBUG_FILENAME, __LINE__, __func__, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG_ASSERT(cond, dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Debug output helper macro
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG(dflag, format, args...) do { if(isDebugLevel(dflag)) \
|
||||
printf("%s:%d:%s(): " format, \
|
||||
_DEBUG_FILENAME, __LINE__, __func__, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG(dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Debug output helper macro to append text without addition information
|
||||
* @param dflag eDebugLevel required to print output
|
||||
* @param format format same as for printf
|
||||
* @param args arguments for printf
|
||||
*
|
||||
* New line must be appended manually
|
||||
*/
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
#define DEBUG_LOG_APPEND(dflag, format, args...) do { if(isDebugLevel(dflag)) \
|
||||
printf(format, ##args); } \
|
||||
while (0)
|
||||
#else
|
||||
#define DEBUG_LOG_APPEND(dflag, format, args...) do{/* nothing */}while(0)
|
||||
#endif
|
||||
|
||||
typedef enum _EDEBUGLEVEL
|
||||
{
|
||||
DEBUG_LEVEL_ALWAYS = 0, /* DEBUG_LOGs are visible regardless of DEBUG_LEVEL */
|
||||
DEBUG_LEVEL_INFO = 1, /* Visible when application started with -v */
|
||||
DEBUG_LEVEL_WARNING = 2, /* Visible when application started with -vv */
|
||||
DEBUG_LEVEL_ERROR = 3,
|
||||
/* Visible when application started with -vvv */
|
||||
} eDebugLevel;
|
||||
|
||||
#endif /* #ifndef _DEBUG_H_INCLUDED */
|
||||
|
@@ -1,79 +1,79 @@
|
||||
/*!
|
||||
* @file xmalloc.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xmalloc.h"
|
||||
#include "xtypes.h"
|
||||
|
||||
void* xmalloc(size_t size)
|
||||
{
|
||||
void *value = malloc(size);
|
||||
if (value == 0)
|
||||
perror("virtual memory exhausted");
|
||||
else
|
||||
memset(value, 0, size);
|
||||
return value;
|
||||
}
|
||||
|
||||
char* xmallocStrlcpy(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
*aDest = (char*) realloc(*aDest, aSize + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aDest = (char*) xmalloc(aSize + 1);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcpy(*aDest, aSource, aSize + 1);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
char* xmallocStrlcat(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
size_t newSize = 0;
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
newSize = strlen(*aDest) + aSize + 1;
|
||||
*aDest = (char*) realloc(*aDest, newSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = aSize + 1;
|
||||
*aDest = (char*) xmalloc(newSize);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcat(*aDest, aSource, newSize);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
void xfree(void **aDest)
|
||||
{
|
||||
free(*aDest);
|
||||
*aDest = NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @file xmalloc.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xmalloc.h"
|
||||
#include "xtypes.h"
|
||||
|
||||
void* xmalloc(size_t size)
|
||||
{
|
||||
void *value = malloc(size);
|
||||
if (value == 0)
|
||||
perror("virtual memory exhausted");
|
||||
else
|
||||
memset(value, 0, size);
|
||||
return value;
|
||||
}
|
||||
|
||||
char* xmallocStrlcpy(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
*aDest = (char*) realloc(*aDest, aSize + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aDest = (char*) xmalloc(aSize + 1);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcpy(*aDest, aSource, aSize + 1);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
char* xmallocStrlcat(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
size_t newSize = 0;
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
newSize = strlen(*aDest) + aSize + 1;
|
||||
*aDest = (char*) realloc(*aDest, newSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = aSize + 1;
|
||||
*aDest = (char*) xmalloc(newSize);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcat(*aDest, aSource, newSize);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
void xfree(void **aDest)
|
||||
{
|
||||
free(*aDest);
|
||||
*aDest = NULL;
|
||||
}
|
||||
|
||||
|
@@ -1,24 +1,24 @@
|
||||
/*!
|
||||
* @file xmalloc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef EXT_XMALLOC_H_
|
||||
#define EXT_XMALLOC_H_
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
void *xmalloc(size_t size);
|
||||
void xfree(void**);
|
||||
char* xmallocStrlcpy(char **aDest, char *aSource, size_t aSize);
|
||||
char* xmallocStrlcat(char **aDest, char *aSource, size_t aSize);
|
||||
|
||||
#endif /* EXT_XMALLOC_H_ */
|
||||
/*!
|
||||
* @file xmalloc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef EXT_XMALLOC_H_
|
||||
#define EXT_XMALLOC_H_
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
void *xmalloc(size_t size);
|
||||
void xfree(void**);
|
||||
char* xmallocStrlcpy(char **aDest, char *aSource, size_t aSize);
|
||||
char* xmallocStrlcat(char **aDest, char *aSource, size_t aSize);
|
||||
|
||||
#endif /* EXT_XMALLOC_H_ */
|
||||
|
@@ -1,22 +1,22 @@
|
||||
/*!
|
||||
* @file xregex.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 01.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef EXT_XREGEX_H_
|
||||
#define EXT_XREGEX_H_
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define XREGEX_IS_MATCHGROUP(groupArray, groupIndex) (groupArray[groupIndex].rm_so < groupArray[groupIndex].rm_eo && 0 <= groupArray[groupIndex].rm_so)
|
||||
#define XREGEX_SIZEOF_MATCHGROUP(groupArray, groupIndex) (size_t) (groupArray[groupIndex].rm_eo - groupArray[groupIndex].rm_so)
|
||||
|
||||
#endif /* EXT_XREGEX_H_ */
|
||||
/*!
|
||||
* @file xregex.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 01.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef EXT_XREGEX_H_
|
||||
#define EXT_XREGEX_H_
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define XREGEX_IS_MATCHGROUP(groupArray, groupIndex) (groupArray[groupIndex].rm_so < groupArray[groupIndex].rm_eo && 0 <= groupArray[groupIndex].rm_so)
|
||||
#define XREGEX_SIZEOF_MATCHGROUP(groupArray, groupIndex) (size_t) (groupArray[groupIndex].rm_eo - groupArray[groupIndex].rm_so)
|
||||
|
||||
#endif /* EXT_XREGEX_H_ */
|
||||
|
@@ -1,154 +1,154 @@
|
||||
/*!
|
||||
* @file xstring.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include "xtypes.h"
|
||||
#include "xstring.h"
|
||||
#include "ctype.h"
|
||||
|
||||
char* gnu_basename(char *path)
|
||||
{
|
||||
char *baseWin = strrchr(path, '\\');
|
||||
char *base = strrchr(path, '/');
|
||||
if (baseWin > base)
|
||||
{
|
||||
base = baseWin;
|
||||
}
|
||||
return base ? base + 1 : path;
|
||||
}
|
||||
|
||||
uint32_t xStrCount(char *aStr, char aC)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
char *temp = NULL;
|
||||
|
||||
if (NULL == aStr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
temp = aStr;
|
||||
|
||||
while (*temp)
|
||||
{
|
||||
if (aC == *temp)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
temp++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Trim leading and trailing whitespaces
|
||||
* @param [in] *str Input string
|
||||
* @retval char* pointer to the trimmed substring
|
||||
*
|
||||
* @details
|
||||
* This function returns a pointer to a substring of the original string.
|
||||
* If the given string was allocated dynamically, the caller must not overwrite
|
||||
* that pointer with the returned value, since the original pointer must be
|
||||
* deallocated using the same allocator with which it was allocated. The return
|
||||
* value must NOT be deallocated using free() etc.
|
||||
*/
|
||||
char* strntrimStatic(char *aStr, size_t aMaxLength)
|
||||
{
|
||||
char *end;
|
||||
|
||||
// Trim leading space
|
||||
while (isspace((unsigned char)*aStr) && 0 < aMaxLength)
|
||||
{
|
||||
if (--aMaxLength > 0)
|
||||
{
|
||||
++aStr;
|
||||
}
|
||||
}
|
||||
|
||||
// All spaces at termination or end of max length
|
||||
if (*aStr == '\0' || 0 == aMaxLength)
|
||||
{
|
||||
return aStr;
|
||||
}
|
||||
|
||||
// Trim trailing space
|
||||
if (strlen(aStr) >= aMaxLength)
|
||||
{
|
||||
end = aStr + aMaxLength - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = aStr + strlen(aStr) - 1;
|
||||
}
|
||||
|
||||
while (end > aStr && isspace((unsigned char )*end))
|
||||
{
|
||||
end--;
|
||||
}
|
||||
|
||||
// Write new null terminator (if length is enough)
|
||||
if (end < (aStr + aMaxLength - 1))
|
||||
{
|
||||
*(end + 1) = '\0';
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
|
||||
void xStringTrim(char *aStr, size_t aMaxLength)
|
||||
{
|
||||
char *start;
|
||||
char *end;
|
||||
|
||||
if (NULL == aStr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
start = aStr;
|
||||
// Trim leading space
|
||||
while (isspace((unsigned char)*aStr) && 0 < aMaxLength)
|
||||
{
|
||||
if (--aMaxLength > 0)
|
||||
{
|
||||
++aStr;
|
||||
}
|
||||
}
|
||||
|
||||
// All spaces at termination or end of max length
|
||||
if (*aStr == '\0' || 0 == aMaxLength)
|
||||
{
|
||||
start = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
(void) strlcpy(start, aStr, strlen(aStr) + 1);
|
||||
|
||||
// Trim trailing space
|
||||
if (strlen(start) >= aMaxLength)
|
||||
{
|
||||
end = start + aMaxLength - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = start + strlen(start) - 1;
|
||||
}
|
||||
|
||||
while (end > start && isspace((unsigned char )*end))
|
||||
{
|
||||
end--;
|
||||
}
|
||||
|
||||
// Write new null terminator (if length is enough)
|
||||
if (end < (start + aMaxLength - 1))
|
||||
{
|
||||
*(end + 1) = '\0';
|
||||
}
|
||||
}
|
||||
/*!
|
||||
* @file xstring.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include "xtypes.h"
|
||||
#include "xstring.h"
|
||||
#include "ctype.h"
|
||||
|
||||
char* gnu_basename(char *path)
|
||||
{
|
||||
char *baseWin = strrchr(path, '\\');
|
||||
char *base = strrchr(path, '/');
|
||||
if (baseWin > base)
|
||||
{
|
||||
base = baseWin;
|
||||
}
|
||||
return base ? base + 1 : path;
|
||||
}
|
||||
|
||||
uint32_t xStrCount(char *aStr, char aC)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
char *temp = NULL;
|
||||
|
||||
if (NULL == aStr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
temp = aStr;
|
||||
|
||||
while (*temp)
|
||||
{
|
||||
if (aC == *temp)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
temp++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Trim leading and trailing whitespaces
|
||||
* @param [in] *str Input string
|
||||
* @retval char* pointer to the trimmed substring
|
||||
*
|
||||
* @details
|
||||
* This function returns a pointer to a substring of the original string.
|
||||
* If the given string was allocated dynamically, the caller must not overwrite
|
||||
* that pointer with the returned value, since the original pointer must be
|
||||
* deallocated using the same allocator with which it was allocated. The return
|
||||
* value must NOT be deallocated using free() etc.
|
||||
*/
|
||||
char* strntrimStatic(char *aStr, size_t aMaxLength)
|
||||
{
|
||||
char *end;
|
||||
|
||||
// Trim leading space
|
||||
while (isspace((unsigned char)*aStr) && 0 < aMaxLength)
|
||||
{
|
||||
if (--aMaxLength > 0)
|
||||
{
|
||||
++aStr;
|
||||
}
|
||||
}
|
||||
|
||||
// All spaces at termination or end of max length
|
||||
if (*aStr == '\0' || 0 == aMaxLength)
|
||||
{
|
||||
return aStr;
|
||||
}
|
||||
|
||||
// Trim trailing space
|
||||
if (strlen(aStr) >= aMaxLength)
|
||||
{
|
||||
end = aStr + aMaxLength - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = aStr + strlen(aStr) - 1;
|
||||
}
|
||||
|
||||
while (end > aStr && isspace((unsigned char )*end))
|
||||
{
|
||||
end--;
|
||||
}
|
||||
|
||||
// Write new null terminator (if length is enough)
|
||||
if (end < (aStr + aMaxLength - 1))
|
||||
{
|
||||
*(end + 1) = '\0';
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
|
||||
void xStringTrim(char *aStr, size_t aMaxLength)
|
||||
{
|
||||
char *start;
|
||||
char *end;
|
||||
|
||||
if (NULL == aStr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
start = aStr;
|
||||
// Trim leading space
|
||||
while (isspace((unsigned char)*aStr) && 0 < aMaxLength)
|
||||
{
|
||||
if (--aMaxLength > 0)
|
||||
{
|
||||
++aStr;
|
||||
}
|
||||
}
|
||||
|
||||
// All spaces at termination or end of max length
|
||||
if (*aStr == '\0' || 0 == aMaxLength)
|
||||
{
|
||||
start = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
(void) strlcpy(start, aStr, strlen(aStr) + 1);
|
||||
|
||||
// Trim trailing space
|
||||
if (strlen(start) >= aMaxLength)
|
||||
{
|
||||
end = start + aMaxLength - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = start + strlen(start) - 1;
|
||||
}
|
||||
|
||||
while (end > start && isspace((unsigned char )*end))
|
||||
{
|
||||
end--;
|
||||
}
|
||||
|
||||
// Write new null terminator (if length is enough)
|
||||
if (end < (start + aMaxLength - 1))
|
||||
{
|
||||
*(end + 1) = '\0';
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,23 @@
|
||||
/*!
|
||||
* @file xstring.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef XSTRING_H_
|
||||
#define XSTRING_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char* gnu_basename(char *path);
|
||||
uint32_t xStrCount(char *aStr, char aC);
|
||||
char* strntrimStatic(char *aStr, size_t aMaxLength);
|
||||
void xStringTrim(char *aStr, size_t aMaxLength);
|
||||
|
||||
#endif /* XSTRING_H_ */
|
||||
/*!
|
||||
* @file xstring.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef XSTRING_H_
|
||||
#define XSTRING_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char* gnu_basename(char *path);
|
||||
uint32_t xStrCount(char *aStr, char aC);
|
||||
char* strntrimStatic(char *aStr, size_t aMaxLength);
|
||||
void xStringTrim(char *aStr, size_t aMaxLength);
|
||||
|
||||
#endif /* XSTRING_H_ */
|
||||
|
@@ -1,32 +1,32 @@
|
||||
/*!
|
||||
* @file xtime.h
|
||||
* @brief Provides additional definitions for working with delays
|
||||
*
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: mst\n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.06.2016
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef XTIME_H_
|
||||
#define XTIME_H_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/*! @brief Convert milliseconds to nanoseconds */
|
||||
#define XTIME_MSTONS(milliseconds) (milliseconds * 1000000L)
|
||||
/*! @brief Convert microseconds to nanoseconds */
|
||||
#define XTIME_USTONS(microseconds) (microseconds * 1000L)
|
||||
/*! @brief Convert nanoseconds to milliseconds*/
|
||||
#define XTIME_NSTOMS(nanoseconds) (nanoseconds / 1000000L)
|
||||
/*! @brief Convert nanoseconds to microseconds*/
|
||||
#define XTIME_NSTOUS(nanoseconds) (nanoseconds / 1000L)
|
||||
|
||||
/*! @brief Only microseconds up to 1000000 are supported */
|
||||
#define XTIME_TIMESPEC_US(seconds, microseconds) (const struct timespec[]){{seconds, XTIME_USTONS(microseconds)}}
|
||||
/*! @brief Only milliseconds up to 1000 are supported */
|
||||
#define XTIME_TIMESPEC_MS(seconds, milliseconds) (const struct timespec[]){{seconds, XTIME_MSTONS(milliseconds)}}
|
||||
|
||||
#endif /* XTIME_H_ */
|
||||
/*!
|
||||
* @file xtime.h
|
||||
* @brief Provides additional definitions for working with delays
|
||||
*
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: mst\n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.06.2016
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef XTIME_H_
|
||||
#define XTIME_H_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/*! @brief Convert milliseconds to nanoseconds */
|
||||
#define XTIME_MSTONS(milliseconds) (milliseconds * 1000000L)
|
||||
/*! @brief Convert microseconds to nanoseconds */
|
||||
#define XTIME_USTONS(microseconds) (microseconds * 1000L)
|
||||
/*! @brief Convert nanoseconds to milliseconds*/
|
||||
#define XTIME_NSTOMS(nanoseconds) (nanoseconds / 1000000L)
|
||||
/*! @brief Convert nanoseconds to microseconds*/
|
||||
#define XTIME_NSTOUS(nanoseconds) (nanoseconds / 1000L)
|
||||
|
||||
/*! @brief Only microseconds up to 1000000 are supported */
|
||||
#define XTIME_TIMESPEC_US(seconds, microseconds) (const struct timespec[]){{seconds, XTIME_USTONS(microseconds)}}
|
||||
/*! @brief Only milliseconds up to 1000 are supported */
|
||||
#define XTIME_TIMESPEC_MS(seconds, milliseconds) (const struct timespec[]){{seconds, XTIME_MSTONS(milliseconds)}}
|
||||
|
||||
#endif /* XTIME_H_ */
|
||||
|
@@ -1,41 +1,41 @@
|
||||
/*!
|
||||
* @file xtypes.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef XTYPES_H_
|
||||
#define XTYPES_H_
|
||||
|
||||
#include <stddef.h> // definition of NULL
|
||||
#include <stdint.h> // fixed width types
|
||||
#include <stdbool.h> // definition of bool
|
||||
|
||||
#define STRINGIZE_2(s) #s
|
||||
/*!
|
||||
* @brief Stringify the content of a definition
|
||||
* @details
|
||||
* Usage example:
|
||||
* @code
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 47
|
||||
|
||||
#define VERSION_STRING "v" STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR)
|
||||
@endcode
|
||||
*/
|
||||
#define STRINGIZE(s) STRINGIZE_2(s)
|
||||
|
||||
#if defined(UNIT_TEST) || defined(_DEBUG)
|
||||
#define STATIC
|
||||
#else
|
||||
#define STATIC static
|
||||
#endif
|
||||
|
||||
#endif /* XTYPES_H_ */
|
||||
/*!
|
||||
* @file xtypes.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef XTYPES_H_
|
||||
#define XTYPES_H_
|
||||
|
||||
#include <stddef.h> // definition of NULL
|
||||
#include <stdint.h> // fixed width types
|
||||
#include <stdbool.h> // definition of bool
|
||||
|
||||
#define STRINGIZE_2(s) #s
|
||||
/*!
|
||||
* @brief Stringify the content of a definition
|
||||
* @details
|
||||
* Usage example:
|
||||
* @code
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 47
|
||||
|
||||
#define VERSION_STRING "v" STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR)
|
||||
@endcode
|
||||
*/
|
||||
#define STRINGIZE(s) STRINGIZE_2(s)
|
||||
|
||||
#if defined(UNIT_TEST) || defined(_DEBUG)
|
||||
#define STATIC
|
||||
#else
|
||||
#define STATIC static
|
||||
#endif
|
||||
|
||||
#endif /* XTYPES_H_ */
|
||||
|
444
src/main.c
444
src/main.c
@@ -1,222 +1,222 @@
|
||||
/*!
|
||||
* @file main.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ftw.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xregex.h"
|
||||
#include "xtypes.h"
|
||||
#include "xstring.h"
|
||||
#include "stubser/stubser_if.h"
|
||||
|
||||
/* POSIX.1 says each process has at least 20 file descriptors.
|
||||
* Three of those belong to the standard streams.
|
||||
* Here, we use a conservative estimate of 15 available;
|
||||
* assuming we use at most two for other uses in this program,
|
||||
* we should never run into any problems.
|
||||
* Most trees are shallower than that, so it is efficient.
|
||||
* Deeper trees are traversed fine, just a bit slower.
|
||||
* (Linux allows typically hundreds to thousands of open files,
|
||||
* so you'll probably never see any issues even if you used
|
||||
* a much higher value, say a couple of hundred, but
|
||||
* 15 is a safe, reasonable value.)
|
||||
*/
|
||||
#ifndef USE_FDS
|
||||
#define USE_FDS 15
|
||||
#endif
|
||||
|
||||
#define MAIN_MAX_MATCHGROUP_FILENAME 2
|
||||
#define MAIN_CFILE_PATTERN "^(.*)\\.+[cC]$"
|
||||
|
||||
STATIC regex_t main_regXcFile;
|
||||
STATIC bool main_recurse = false;
|
||||
STATIC char* main_outputDir = NULL;
|
||||
|
||||
/*!
|
||||
* @brief Using regular expressions to scan for c files, extract filename without suffix and start stub creation
|
||||
* @details
|
||||
* @par Parameter
|
||||
* See gnu libc documentation for details (Data Type: __nftw_func_t).
|
||||
*/
|
||||
int evaluateEntry(const char *filepath, const struct stat *info, const int typeflag, struct FTW *pathinfo)
|
||||
{
|
||||
regmatch_t matchGroup[MAIN_MAX_MATCHGROUP_FILENAME];
|
||||
char *noSuffix = NULL;
|
||||
if (!main_recurse && 1 < pathinfo->level)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (typeflag != FTW_F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (0 != regexec(&main_regXcFile, gnu_basename((char*) filepath), MAIN_MAX_MATCHGROUP_FILENAME, matchGroup, 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (XREGEX_IS_MATCHGROUP(matchGroup, 1))
|
||||
{
|
||||
xmallocStrlcpy(&noSuffix, &gnu_basename((char*) filepath)[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
||||
if (NULL != noSuffix)
|
||||
{
|
||||
stubser_createStub((char*) filepath, noSuffix, main_outputDir);
|
||||
}
|
||||
free(noSuffix);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Scan given directory recursively
|
||||
*/
|
||||
int evaluateDirectoryTree(const char * const dirpath)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* Invalid directory path? */
|
||||
if (dirpath == NULL || *dirpath == '\0')
|
||||
return errno = EINVAL;
|
||||
|
||||
result = nftw(dirpath, evaluateEntry, USE_FDS, FTW_PHYS);
|
||||
if (result >= 0)
|
||||
errno = result;
|
||||
|
||||
return errno;
|
||||
}
|
||||
|
||||
void printUsage(char *aAppName)
|
||||
{
|
||||
printf("%s version: %s\n", aAppName, GITVERSION);
|
||||
printf("Create stub c-files and c-header from c files for CUnit.\n\n");
|
||||
printf("Usage:\n");
|
||||
printf(" %s [options] [source dir] <target dir>\n", aAppName);
|
||||
printf("\nOptions:\n");
|
||||
printf(" -h, --help \tShow usage\n");
|
||||
printf(" -r, --recurse\tSearch source Dir recursively\n");
|
||||
printf(" --version \tShow version\n");
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Search (optionally recursive) for c file and create stubs
|
||||
* @param [in] argc Amount of command line arguments
|
||||
* @param [in] **argv Array of arguments
|
||||
* @retval EXIT_SUCCESS stubs created successfully
|
||||
* @retval EXIT_FAILURE error with arguments or input
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = 0;
|
||||
int ret = EXIT_FAILURE;
|
||||
int outputDirIndex = 0;
|
||||
uint8_t dirs = 0;
|
||||
|
||||
if (regcomp(&main_regXcFile, MAIN_CFILE_PATTERN, REG_EXTENDED | REG_NEWLINE))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
// evaluate command line parameter
|
||||
for (i = 1; i < argc && i < 4; ++i)
|
||||
{
|
||||
if (NULL != strstr(argv[i], "-r") || NULL != strstr(argv[i], "--recurse"))
|
||||
{
|
||||
main_recurse = true;
|
||||
}
|
||||
else if (NULL != strstr(argv[i], "--version"))
|
||||
{
|
||||
printf("%s version: %s", gnu_basename(argv[0]), GITVERSION);
|
||||
goto l_main_end;
|
||||
}
|
||||
else if (NULL != strstr(argv[i], "-h") || NULL != strstr(argv[i], "--help"))
|
||||
{
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
goto l_main_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDirIndex = i;
|
||||
++dirs;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == outputDirIndex)
|
||||
{
|
||||
// only options; no output directory provided
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (0 > mkdir(argv[outputDirIndex], S_IRWXU))
|
||||
{
|
||||
// output directory not available
|
||||
if (EEXIST != errno)
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
|
||||
xmallocStrlcpy(&main_outputDir, argv[outputDirIndex], strlen(argv[outputDirIndex]) + 1);
|
||||
if (NULL == main_outputDir)
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (1 == dirs)
|
||||
{
|
||||
// only output provided; input will be "."
|
||||
if (evaluateDirectoryTree("."))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// take input directory from arguments
|
||||
if (evaluateDirectoryTree(argv[outputDirIndex - 1]))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
l_main_end: // label for ending main
|
||||
|
||||
free(main_outputDir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/*!
|
||||
* @file main.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ftw.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xregex.h"
|
||||
#include "xtypes.h"
|
||||
#include "xstring.h"
|
||||
#include "stubser/stubser_if.h"
|
||||
|
||||
/* POSIX.1 says each process has at least 20 file descriptors.
|
||||
* Three of those belong to the standard streams.
|
||||
* Here, we use a conservative estimate of 15 available;
|
||||
* assuming we use at most two for other uses in this program,
|
||||
* we should never run into any problems.
|
||||
* Most trees are shallower than that, so it is efficient.
|
||||
* Deeper trees are traversed fine, just a bit slower.
|
||||
* (Linux allows typically hundreds to thousands of open files,
|
||||
* so you'll probably never see any issues even if you used
|
||||
* a much higher value, say a couple of hundred, but
|
||||
* 15 is a safe, reasonable value.)
|
||||
*/
|
||||
#ifndef USE_FDS
|
||||
#define USE_FDS 15
|
||||
#endif
|
||||
|
||||
#define MAIN_MAX_MATCHGROUP_FILENAME 2
|
||||
#define MAIN_CFILE_PATTERN "^(.*)\\.+[cC]$"
|
||||
|
||||
STATIC regex_t main_regXcFile;
|
||||
STATIC bool main_recurse = false;
|
||||
STATIC char* main_outputDir = NULL;
|
||||
|
||||
/*!
|
||||
* @brief Using regular expressions to scan for c files, extract filename without suffix and start stub creation
|
||||
* @details
|
||||
* @par Parameter
|
||||
* See gnu libc documentation for details (Data Type: __nftw_func_t).
|
||||
*/
|
||||
int evaluateEntry(const char *filepath, const struct stat *info, const int typeflag, struct FTW *pathinfo)
|
||||
{
|
||||
regmatch_t matchGroup[MAIN_MAX_MATCHGROUP_FILENAME];
|
||||
char *noSuffix = NULL;
|
||||
if (!main_recurse && 1 < pathinfo->level)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (typeflag != FTW_F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (0 != regexec(&main_regXcFile, gnu_basename((char*) filepath), MAIN_MAX_MATCHGROUP_FILENAME, matchGroup, 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (XREGEX_IS_MATCHGROUP(matchGroup, 1))
|
||||
{
|
||||
xmallocStrlcpy(&noSuffix, &gnu_basename((char*) filepath)[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
||||
if (NULL != noSuffix)
|
||||
{
|
||||
stubser_createStub((char*) filepath, noSuffix, main_outputDir);
|
||||
}
|
||||
free(noSuffix);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Scan given directory recursively
|
||||
*/
|
||||
int evaluateDirectoryTree(const char * const dirpath)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* Invalid directory path? */
|
||||
if (dirpath == NULL || *dirpath == '\0')
|
||||
return errno = EINVAL;
|
||||
|
||||
result = nftw(dirpath, evaluateEntry, USE_FDS, FTW_PHYS);
|
||||
if (result >= 0)
|
||||
errno = result;
|
||||
|
||||
return errno;
|
||||
}
|
||||
|
||||
void printUsage(char *aAppName)
|
||||
{
|
||||
printf("%s version: %s\n", aAppName, GITVERSION);
|
||||
printf("Create stub c-files and c-header from c files for CUnit.\n\n");
|
||||
printf("Usage:\n");
|
||||
printf(" %s [options] [source dir] <target dir>\n", aAppName);
|
||||
printf("\nOptions:\n");
|
||||
printf(" -h, --help \tShow usage\n");
|
||||
printf(" -r, --recurse\tSearch source Dir recursively\n");
|
||||
printf(" --version \tShow version\n");
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Search (optionally recursive) for c file and create stubs
|
||||
* @param [in] argc Amount of command line arguments
|
||||
* @param [in] **argv Array of arguments
|
||||
* @retval EXIT_SUCCESS stubs created successfully
|
||||
* @retval EXIT_FAILURE error with arguments or input
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = 0;
|
||||
int ret = EXIT_FAILURE;
|
||||
int outputDirIndex = 0;
|
||||
uint8_t dirs = 0;
|
||||
|
||||
if (regcomp(&main_regXcFile, MAIN_CFILE_PATTERN, REG_EXTENDED | REG_NEWLINE))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
// evaluate command line parameter
|
||||
for (i = 1; i < argc && i < 4; ++i)
|
||||
{
|
||||
if (NULL != strstr(argv[i], "-r") || NULL != strstr(argv[i], "--recurse"))
|
||||
{
|
||||
main_recurse = true;
|
||||
}
|
||||
else if (NULL != strstr(argv[i], "--version"))
|
||||
{
|
||||
printf("%s version: %s", gnu_basename(argv[0]), GITVERSION);
|
||||
goto l_main_end;
|
||||
}
|
||||
else if (NULL != strstr(argv[i], "-h") || NULL != strstr(argv[i], "--help"))
|
||||
{
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
goto l_main_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDirIndex = i;
|
||||
++dirs;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == outputDirIndex)
|
||||
{
|
||||
// only options; no output directory provided
|
||||
printUsage(gnu_basename(argv[0]));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (0 > mkdir(argv[outputDirIndex], S_IRWXU))
|
||||
{
|
||||
// output directory not available
|
||||
if (EEXIST != errno)
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
|
||||
xmallocStrlcpy(&main_outputDir, argv[outputDirIndex], strlen(argv[outputDirIndex]) + 1);
|
||||
if (NULL == main_outputDir)
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
|
||||
if (1 == dirs)
|
||||
{
|
||||
// only output provided; input will be "."
|
||||
if (evaluateDirectoryTree("."))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// take input directory from arguments
|
||||
if (evaluateDirectoryTree(argv[outputDirIndex - 1]))
|
||||
{
|
||||
fprintf(stderr, "%s.\n", strerror(errno));
|
||||
ret = EXIT_FAILURE;
|
||||
goto l_main_end;
|
||||
}
|
||||
}
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
l_main_end: // label for ending main
|
||||
|
||||
free(main_outputDir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -1,163 +1,163 @@
|
||||
/*!
|
||||
* @file cfile.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xtypes.h"
|
||||
#include "xmalloc.h"
|
||||
#include "cfile_if.h"
|
||||
|
||||
cfile_variable_t* cfile_newVariable(cfile_variableList_t *aList)
|
||||
{
|
||||
cfile_variable_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfile_variable_t*) xmalloc(sizeof(cfile_variable_t));
|
||||
memset(new, 0, sizeof(cfile_variable_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
int8_t cfile_freeVariables(cfile_variableList_t *aVariable)
|
||||
{
|
||||
cfile_variable_t *work = NULL;
|
||||
cfile_variable_t *next = NULL;
|
||||
|
||||
if (NULL == aVariable)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aVariable->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
free(work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aVariable->amount = 0;
|
||||
aVariable->head = NULL;
|
||||
aVariable->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cfile_free(cfile_t *aCfile)
|
||||
{
|
||||
cfile_freeVariables(&aCfile->variables);
|
||||
cfunction_freeList(&aCfile->functions);
|
||||
}
|
||||
|
||||
void cfile_print(cfile_t *aCfile)
|
||||
{
|
||||
cfile_variable_t *work = NULL;
|
||||
|
||||
if (NULL == aCfile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
work = aCfile->variables.head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
printf("[ cva]%d:<%s> (%s) %s %s\n", work->type, work->prefix, work->dataType, work->name, work->array);
|
||||
work = work->next;
|
||||
}
|
||||
|
||||
cfunction_printList(&aCfile->functions);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Checks if at least one function uses a variable parameter list
|
||||
* @retval -2 Null pointer parameter
|
||||
* @retval -1 Has no va_list
|
||||
* @retval 0 At least on va_list
|
||||
*/
|
||||
int8_t cfile_hasVaList(cfile_t *aFile)
|
||||
{
|
||||
cfunction_t *function = aFile->functions.head;
|
||||
cfunction_parameterList_t *paraList = NULL;
|
||||
cfunction_parameter_t *parameter;
|
||||
if (NULL == aFile)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
while(function)
|
||||
{
|
||||
paraList = &function->parameter;
|
||||
parameter = paraList->head;
|
||||
while(parameter)
|
||||
{
|
||||
if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
parameter = parameter->next;
|
||||
}
|
||||
function = function->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Checks if at least one variable or function parameter is a pointer
|
||||
* @retval -2 Null pointer parameter
|
||||
* @retval -1 Has no pointer
|
||||
* @retval 0 At least on pointer
|
||||
*/
|
||||
int8_t cfile_hasPointerParameter(cfile_t *aFile)
|
||||
{
|
||||
cfunction_t *function = aFile->functions.head;
|
||||
cfunction_parameterList_t *paraList = NULL;
|
||||
cfunction_parameter_t *parameter;
|
||||
if (NULL == aFile)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
while(function)
|
||||
{
|
||||
paraList = &function->parameter;
|
||||
parameter = paraList->head;
|
||||
while(parameter)
|
||||
{
|
||||
if (NULL != strstr(parameter->dataType, "*") || NULL != parameter->array)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
parameter = parameter->next;
|
||||
}
|
||||
function = function->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/*!
|
||||
* @file cfile.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xtypes.h"
|
||||
#include "xmalloc.h"
|
||||
#include "cfile_if.h"
|
||||
|
||||
cfile_variable_t* cfile_newVariable(cfile_variableList_t *aList)
|
||||
{
|
||||
cfile_variable_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfile_variable_t*) xmalloc(sizeof(cfile_variable_t));
|
||||
memset(new, 0, sizeof(cfile_variable_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
int8_t cfile_freeVariables(cfile_variableList_t *aVariable)
|
||||
{
|
||||
cfile_variable_t *work = NULL;
|
||||
cfile_variable_t *next = NULL;
|
||||
|
||||
if (NULL == aVariable)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aVariable->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
free(work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aVariable->amount = 0;
|
||||
aVariable->head = NULL;
|
||||
aVariable->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cfile_free(cfile_t *aCfile)
|
||||
{
|
||||
cfile_freeVariables(&aCfile->variables);
|
||||
cfunction_freeList(&aCfile->functions);
|
||||
}
|
||||
|
||||
void cfile_print(cfile_t *aCfile)
|
||||
{
|
||||
cfile_variable_t *work = NULL;
|
||||
|
||||
if (NULL == aCfile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
work = aCfile->variables.head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
printf("[ cva]%d:<%s> (%s) %s %s\n", work->type, work->prefix, work->dataType, work->name, work->array);
|
||||
work = work->next;
|
||||
}
|
||||
|
||||
cfunction_printList(&aCfile->functions);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Checks if at least one function uses a variable parameter list
|
||||
* @retval -2 Null pointer parameter
|
||||
* @retval -1 Has no va_list
|
||||
* @retval 0 At least on va_list
|
||||
*/
|
||||
int8_t cfile_hasVaList(cfile_t *aFile)
|
||||
{
|
||||
cfunction_t *function = aFile->functions.head;
|
||||
cfunction_parameterList_t *paraList = NULL;
|
||||
cfunction_parameter_t *parameter;
|
||||
if (NULL == aFile)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
while(function)
|
||||
{
|
||||
paraList = &function->parameter;
|
||||
parameter = paraList->head;
|
||||
while(parameter)
|
||||
{
|
||||
if (CPARAMETER_TYPE_VARIABLE == parameter->type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
parameter = parameter->next;
|
||||
}
|
||||
function = function->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Checks if at least one variable or function parameter is a pointer
|
||||
* @retval -2 Null pointer parameter
|
||||
* @retval -1 Has no pointer
|
||||
* @retval 0 At least on pointer
|
||||
*/
|
||||
int8_t cfile_hasPointerParameter(cfile_t *aFile)
|
||||
{
|
||||
cfunction_t *function = aFile->functions.head;
|
||||
cfunction_parameterList_t *paraList = NULL;
|
||||
cfunction_parameter_t *parameter;
|
||||
if (NULL == aFile)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
while(function)
|
||||
{
|
||||
paraList = &function->parameter;
|
||||
parameter = paraList->head;
|
||||
while(parameter)
|
||||
{
|
||||
if (NULL != strstr(parameter->dataType, "*") || NULL != parameter->array)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
parameter = parameter->next;
|
||||
}
|
||||
function = function->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@@ -1,76 +1,76 @@
|
||||
/*!
|
||||
* @file cfile_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_IF_H_
|
||||
#define STUBSER_CFILE_IF_H_
|
||||
|
||||
#include "cfunction_if.h"
|
||||
|
||||
#define CVARIABLE_CHECK_TYPE(var, type) (type == (var & type))
|
||||
#define CVARIABLE_SET_TYPE(var, type) do{\
|
||||
var &= ~type; \
|
||||
var |= type; \
|
||||
} while(0)
|
||||
|
||||
/*! @brief Type of variable definition for bit field usage */
|
||||
typedef enum _CFILE_VARIABLE_TYPE_T
|
||||
{
|
||||
CVARIABLE_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CVARIABLE_TYPE_REGULAR = 0x01, /*!< @brief Regular C variable definition */
|
||||
CVARIABLE_TYPE_STATIC = 0x02, /*!< @brief Static C variable definition */
|
||||
CVARIABLE_TYPE_EXTERN = 0x04, /*!< @brief External C variable definition */
|
||||
CVARIABLE_TYPE_FUPTR = 0x08, /*!< @brief Function pointer as variable */
|
||||
CVARIABLE_TYPE_CONST = 0x10, /*!< @brief Const C variable */
|
||||
CVARIABLE_TYPE_LAST_ENUM
|
||||
} cfile_variable_type_t;
|
||||
|
||||
/*! @brief Parameter list node */
|
||||
typedef struct _CFILE_VARIABLE_T
|
||||
{
|
||||
cfile_variable_type_t type;
|
||||
char* prefix; /*!< @brief variable prefix (e.g. static) */
|
||||
char* dataType; /*!< @brief data type */
|
||||
char* name; /*!< @brief name */
|
||||
char* array; /*!< @brief array information (e.g. [10] or [DEF_MAX]) */
|
||||
struct _CFILE_VARIABLE_T *next;
|
||||
} cfile_variable_t;
|
||||
|
||||
/*! @brief parameter array */
|
||||
typedef struct _CFILE_VARIABLE_LIST_T
|
||||
{
|
||||
uint8_t amount;
|
||||
cfile_variable_t *head;
|
||||
cfile_variable_t *current;
|
||||
} cfile_variableList_t;
|
||||
|
||||
/*! @brief brief_description */
|
||||
typedef struct _CFILE_T
|
||||
{
|
||||
cfile_variableList_t variables; /*! @brief C variables */
|
||||
cfunction_list_t functions; /*!< @brief C functions */
|
||||
} cfile_t;
|
||||
|
||||
#define CFILE_T_DEFAULT {\
|
||||
.variables.amount = 0, \
|
||||
.variables.head = NULL, \
|
||||
.variables.current = NULL, \
|
||||
.functions = CFUNCTION_LIST_DEFAULT }
|
||||
|
||||
cfile_variable_t* cfile_newVariable(cfile_variableList_t *aList);
|
||||
int8_t cfile_freeVariables(cfile_variableList_t *aVariable);
|
||||
void cfile_free(cfile_t *aCfile);
|
||||
void cfile_print(cfile_t *aCfile);
|
||||
int8_t cfile_hasVaList(cfile_t *aFile);
|
||||
int8_t cfile_hasPointerParameter(cfile_t *aFile);
|
||||
|
||||
#endif /* STUBSER_CFILE_IF_H_ */
|
||||
/*!
|
||||
* @file cfile_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 08.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_IF_H_
|
||||
#define STUBSER_CFILE_IF_H_
|
||||
|
||||
#include "cfunction_if.h"
|
||||
|
||||
#define CVARIABLE_CHECK_TYPE(var, type) (type == (var & type))
|
||||
#define CVARIABLE_SET_TYPE(var, type) do{\
|
||||
var &= ~type; \
|
||||
var |= type; \
|
||||
} while(0)
|
||||
|
||||
/*! @brief Type of variable definition for bit field usage */
|
||||
typedef enum _CFILE_VARIABLE_TYPE_T
|
||||
{
|
||||
CVARIABLE_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CVARIABLE_TYPE_REGULAR = 0x01, /*!< @brief Regular C variable definition */
|
||||
CVARIABLE_TYPE_STATIC = 0x02, /*!< @brief Static C variable definition */
|
||||
CVARIABLE_TYPE_EXTERN = 0x04, /*!< @brief External C variable definition */
|
||||
CVARIABLE_TYPE_FUPTR = 0x08, /*!< @brief Function pointer as variable */
|
||||
CVARIABLE_TYPE_CONST = 0x10, /*!< @brief Const C variable */
|
||||
CVARIABLE_TYPE_LAST_ENUM
|
||||
} cfile_variable_type_t;
|
||||
|
||||
/*! @brief Parameter list node */
|
||||
typedef struct _CFILE_VARIABLE_T
|
||||
{
|
||||
cfile_variable_type_t type;
|
||||
char* prefix; /*!< @brief variable prefix (e.g. static) */
|
||||
char* dataType; /*!< @brief data type */
|
||||
char* name; /*!< @brief name */
|
||||
char* array; /*!< @brief array information (e.g. [10] or [DEF_MAX]) */
|
||||
struct _CFILE_VARIABLE_T *next;
|
||||
} cfile_variable_t;
|
||||
|
||||
/*! @brief parameter array */
|
||||
typedef struct _CFILE_VARIABLE_LIST_T
|
||||
{
|
||||
uint8_t amount;
|
||||
cfile_variable_t *head;
|
||||
cfile_variable_t *current;
|
||||
} cfile_variableList_t;
|
||||
|
||||
/*! @brief brief_description */
|
||||
typedef struct _CFILE_T
|
||||
{
|
||||
cfile_variableList_t variables; /*! @brief C variables */
|
||||
cfunction_list_t functions; /*!< @brief C functions */
|
||||
} cfile_t;
|
||||
|
||||
#define CFILE_T_DEFAULT {\
|
||||
.variables.amount = 0, \
|
||||
.variables.head = NULL, \
|
||||
.variables.current = NULL, \
|
||||
.functions = CFUNCTION_LIST_DEFAULT }
|
||||
|
||||
cfile_variable_t* cfile_newVariable(cfile_variableList_t *aList);
|
||||
int8_t cfile_freeVariables(cfile_variableList_t *aVariable);
|
||||
void cfile_free(cfile_t *aCfile);
|
||||
void cfile_print(cfile_t *aCfile);
|
||||
int8_t cfile_hasVaList(cfile_t *aFile);
|
||||
int8_t cfile_hasPointerParameter(cfile_t *aFile);
|
||||
|
||||
#endif /* STUBSER_CFILE_IF_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,21 @@
|
||||
/*!
|
||||
* @file cfile_parser_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_PARSER_IF_H_
|
||||
#define STUBSER_CFILE_PARSER_IF_H_
|
||||
|
||||
#define CPARS_ELEMENT_CONST "const"
|
||||
|
||||
uint32_t cfile_parser(char *aPath, cfile_t *aList);
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_IF_H_ */
|
||||
/*!
|
||||
* @file cfile_parser_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_PARSER_IF_H_
|
||||
#define STUBSER_CFILE_PARSER_IF_H_
|
||||
|
||||
#define CPARS_ELEMENT_CONST "const"
|
||||
|
||||
uint32_t cfile_parser(char *aPath, cfile_t *aList);
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_IF_H_ */
|
||||
|
@@ -1,57 +1,57 @@
|
||||
/*!
|
||||
* @file cfile_parser_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef STUBSER_CFILE_PARSER_LOC_H_
|
||||
#define STUBSER_CFILE_PARSER_LOC_H_
|
||||
|
||||
#define CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS 10
|
||||
|
||||
#define CPARS_LINE_ENDING "\r\n"
|
||||
#define CPARS_COMMENT_INLINE "//"
|
||||
#define CPARS_COMMENT_BLOCK_START "/*"
|
||||
#define CPARS_COMMENT_BLOCK_END "*/"
|
||||
|
||||
#define CPARS_PROTOTYPE_END_C ';'
|
||||
#define CPARS_PREFIX_STATIC_S "static"
|
||||
#define CPARS_PREFIX_STATIC2_S "STATIC"
|
||||
#define CPARS_PREFIX_EXTERN_S "extern"
|
||||
|
||||
#define CPARS_EXPRESSION_BASE "^[[:blank:]]*([ _\\*[:alnum:]]*[[:blank:]]+\\**)([_\\*[:alnum:]]+)"
|
||||
#define CPARS_REGEX_FUNCTIONPOINTER "^[[:blank:]]*([ _\\*[:alnum:]]* +\\**)\\(([_\\*[:alnum:]]+)\\)(\\([^\\)]*\\))"
|
||||
|
||||
#define FUNCTION_BASE CPARS_EXPRESSION_BASE "[[:blank:]]*\\([[:blank:]]*"
|
||||
#define CPARS_REGEX_FUNCTION FUNCTION_BASE "(.*)\\)[[:blank:]\\{\\};]+[[:blank:]]*"
|
||||
#define CPARS_REGEX_VARIABLE CPARS_EXPRESSION_BASE "[[:blank:]]*(\\[*[^;=,]*)[[:blank:]]*(\\[*[^;=]*[;=])"
|
||||
#define CPARS_REGEX_PARAMETER CPARS_EXPRESSION_BASE "[[:blank:]]*(\\[*[^;=]*)"
|
||||
#define CPARS_STRCMP_PARAMETER_VARIABLE "..."
|
||||
#define CPARS_REGEX_PARAMETER_FUPTR_SEPA "\\([^\\,)]*(,)" // function pointer parameter separation
|
||||
#define CPARS_REGEX_PREFIX "("CPARS_PREFIX_EXTERN_S"|EXTERN|"CPARS_PREFIX_STATIC_S"|STATIC|volatile|near|far)[[:blank:]]*(.*)"
|
||||
|
||||
#define CPARS_EXPRESSION_START "^[[:blank:]]*([A-Za-z\\_][\\_\\*[:alnum:]]*)"
|
||||
#define CPARS_EXPRESSION_END "[[:blank:]]*([\\};]+)"
|
||||
|
||||
#define CPARS_WARNING_START " W-> "
|
||||
|
||||
#define CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup) (XREGEX_IS_MATCHGROUP(matchGroup, 1) && XREGEX_IS_MATCHGROUP(matchGroup, 2))
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CELEMENT_TYPE_T
|
||||
{
|
||||
CELEMENT_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CELEMENT_TYPE_INCLUDE = 1, /*!< @brief C #include */
|
||||
CELEMENT_TYPE_DEFINE = 2, /*!< @brief C #define */
|
||||
CELEMENT_TYPE_VARIABLE = 3, /*!< @brief Prototype C variable definition */
|
||||
CELEMENT_TYPE_FUNCTION = 4, /*!< @brief Prototype C function definition */
|
||||
CELEMENT_TYPE_LAST_ENUM
|
||||
} celement_type_t;
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_LOC_H_ */
|
||||
/*!
|
||||
* @file cfile_parser_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#ifndef STUBSER_CFILE_PARSER_LOC_H_
|
||||
#define STUBSER_CFILE_PARSER_LOC_H_
|
||||
|
||||
#define CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS 10
|
||||
|
||||
#define CPARS_LINE_ENDING "\r\n"
|
||||
#define CPARS_COMMENT_INLINE "//"
|
||||
#define CPARS_COMMENT_BLOCK_START "/*"
|
||||
#define CPARS_COMMENT_BLOCK_END "*/"
|
||||
|
||||
#define CPARS_PROTOTYPE_END_C ';'
|
||||
#define CPARS_PREFIX_STATIC_S "static"
|
||||
#define CPARS_PREFIX_STATIC2_S "STATIC"
|
||||
#define CPARS_PREFIX_EXTERN_S "extern"
|
||||
|
||||
#define CPARS_EXPRESSION_BASE "^[[:blank:]]*([ _\\*[:alnum:]]*[[:blank:]]+\\**)([_\\*[:alnum:]]+)"
|
||||
#define CPARS_REGEX_FUNCTIONPOINTER "^[[:blank:]]*([ _\\*[:alnum:]]* +\\**)\\(([_\\*[:alnum:]]+)\\)(\\([^\\)]*\\))"
|
||||
|
||||
#define FUNCTION_BASE CPARS_EXPRESSION_BASE "[[:blank:]]*\\([[:blank:]]*"
|
||||
#define CPARS_REGEX_FUNCTION FUNCTION_BASE "(.*)\\)[[:blank:]\\{\\};]+[[:blank:]]*"
|
||||
#define CPARS_REGEX_VARIABLE CPARS_EXPRESSION_BASE "[[:blank:]]*(\\[*[^;=,]*)[[:blank:]]*(\\[*[^;=]*[;=])"
|
||||
#define CPARS_REGEX_PARAMETER CPARS_EXPRESSION_BASE "[[:blank:]]*(\\[*[^;=]*)"
|
||||
#define CPARS_STRCMP_PARAMETER_VARIABLE "..."
|
||||
#define CPARS_REGEX_PARAMETER_FUPTR_SEPA "\\([^\\,)]*(,)" // function pointer parameter separation
|
||||
#define CPARS_REGEX_PREFIX "("CPARS_PREFIX_EXTERN_S"|EXTERN|"CPARS_PREFIX_STATIC_S"|STATIC|volatile|near|far)[[:blank:]]*(.*)"
|
||||
|
||||
#define CPARS_EXPRESSION_START "^[[:blank:]]*([A-Za-z\\_][\\_\\*[:alnum:]]*)"
|
||||
#define CPARS_EXPRESSION_END "[[:blank:]]*([\\};]+)"
|
||||
|
||||
#define CPARS_WARNING_START " W-> "
|
||||
|
||||
#define CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup) (XREGEX_IS_MATCHGROUP(matchGroup, 1) && XREGEX_IS_MATCHGROUP(matchGroup, 2))
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CELEMENT_TYPE_T
|
||||
{
|
||||
CELEMENT_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CELEMENT_TYPE_INCLUDE = 1, /*!< @brief C #include */
|
||||
CELEMENT_TYPE_DEFINE = 2, /*!< @brief C #define */
|
||||
CELEMENT_TYPE_VARIABLE = 3, /*!< @brief Prototype C variable definition */
|
||||
CELEMENT_TYPE_FUNCTION = 4, /*!< @brief Prototype C function definition */
|
||||
CELEMENT_TYPE_LAST_ENUM
|
||||
} celement_type_t;
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_LOC_H_ */
|
||||
|
@@ -1,152 +1,152 @@
|
||||
/*!
|
||||
* @file cfile_parser_worker.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 09.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#include "xtypes.h"
|
||||
#include "xregex.h"
|
||||
#include "xmalloc.h"
|
||||
#include "debug.h"
|
||||
#include "cfile_parser_loc.h"
|
||||
#include "cfile_parser_worker_loc.h"
|
||||
|
||||
/*!
|
||||
* @brief String block detection using regular expressions
|
||||
* @attention Recursive function (calls itself to find block end on same line)
|
||||
* @param [out] **aOutput Matched group content across multiple calls (will be allocated as needed)
|
||||
* @param [in,out] **aInput Char pointer to search string (will be moved to position after match)
|
||||
* @param [in] *aStart Regular expression defining block start
|
||||
* @param [in] *aEnd Regular expression defining block end
|
||||
* @param [out] *aBlockDepth Current depth of parsing
|
||||
* @param [in] aMultiLevel false - starts within block are ignored
|
||||
* @return Matched string and various information about the parsing
|
||||
* @retval uint32_t amount of warnings during parser run
|
||||
*
|
||||
* @details
|
||||
* - Parsing done when (match && 0 == aBlockDepth)
|
||||
* - Orphan end markers are ignored and skipped.
|
||||
*/
|
||||
uint32_t regExWorker(char **aOutput, char **aInput, const regex_t *aStart, const regex_t *aEnd, uint8_t *aBlockDepth, bool aMultiLevel)
|
||||
{
|
||||
uint32_t warningCounter = 0;
|
||||
regmatch_t matchStart[2];
|
||||
regmatch_t matchEnd[2];
|
||||
regmatch_t *match = NULL;
|
||||
char *begin = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
if (!**aInput || NULL == *aInput)
|
||||
{
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
xmallocStrlcat(aOutput, " ", 2);
|
||||
}
|
||||
*aInput = NULL;
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
// start
|
||||
if (0 == regexec(aStart, *aInput, 2, matchStart, REG_NOTEOL) && XREGEX_IS_MATCHGROUP(matchStart, 1))
|
||||
{
|
||||
match = matchStart;
|
||||
}
|
||||
|
||||
// end < start
|
||||
if (0 == regexec(aEnd, *aInput, 2, matchEnd, REG_NOTEOL) && XREGEX_IS_MATCHGROUP(matchEnd, 1))
|
||||
{
|
||||
if (match && match->rm_so > matchEnd[1].rm_so)
|
||||
{
|
||||
match = matchEnd;
|
||||
}
|
||||
else if (!match)
|
||||
{
|
||||
match = matchEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
begin = *aInput;
|
||||
size = strlen(*aInput);
|
||||
if (!match)
|
||||
{
|
||||
// complete line within block
|
||||
*aInput += strlen(*aInput);
|
||||
goto regExWorker_end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin = NULL;
|
||||
// no findings
|
||||
if (!match)
|
||||
{
|
||||
// skip remaining character within line without match
|
||||
*aInput += strlen(*aInput);
|
||||
goto regExWorker_end;
|
||||
}
|
||||
}
|
||||
|
||||
if (match == matchStart)
|
||||
{
|
||||
if ((*aBlockDepth && aMultiLevel) || 0 == *aBlockDepth)
|
||||
{
|
||||
DEBUG_LOG_APPEND(2, "[ CEs]");
|
||||
++*aBlockDepth;
|
||||
size = XREGEX_SIZEOF_MATCHGROUP(match, 1);
|
||||
//begin = *aInput + match[1].rm_eo; // don't include start marker in result
|
||||
begin = *aInput + match[1].rm_so; // include start marker in result
|
||||
*aInput += match[1].rm_eo;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ignore starts within block
|
||||
size = match->rm_eo;
|
||||
*aInput += match->rm_eo;
|
||||
}
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
if (match == matchEnd)
|
||||
{
|
||||
DEBUG_LOG_APPEND(2, "[ CEe]");
|
||||
//size = match[1].rm_so; // don't include end marker in result
|
||||
size = match[1].rm_eo; // include end marker in result
|
||||
*aInput += match[1].rm_eo;
|
||||
if (0 < *aBlockDepth)
|
||||
{
|
||||
--*aBlockDepth;
|
||||
}
|
||||
// TODO orphan end markers
|
||||
// must be evaluated depending on expression
|
||||
// e.g. array[]={}; -> must have } and ;
|
||||
// function{} -> must not have ;
|
||||
// else
|
||||
// {
|
||||
// // orphan end marker
|
||||
// ++warningCounter;
|
||||
// }
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
regExWorker_end:
|
||||
|
||||
if (begin)
|
||||
{
|
||||
xmallocStrlcat(aOutput, begin, size);
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
warningCounter += regExWorker(aOutput, aInput, aStart, aEnd, aBlockDepth, aMultiLevel);
|
||||
}
|
||||
}
|
||||
|
||||
return warningCounter;
|
||||
}
|
||||
/*!
|
||||
* @file cfile_parser_worker.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 09.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#include "xtypes.h"
|
||||
#include "xregex.h"
|
||||
#include "xmalloc.h"
|
||||
#include "debug.h"
|
||||
#include "cfile_parser_loc.h"
|
||||
#include "cfile_parser_worker_loc.h"
|
||||
|
||||
/*!
|
||||
* @brief String block detection using regular expressions
|
||||
* @attention Recursive function (calls itself to find block end on same line)
|
||||
* @param [out] **aOutput Matched group content across multiple calls (will be allocated as needed)
|
||||
* @param [in,out] **aInput Char pointer to search string (will be moved to position after match)
|
||||
* @param [in] *aStart Regular expression defining block start
|
||||
* @param [in] *aEnd Regular expression defining block end
|
||||
* @param [out] *aBlockDepth Current depth of parsing
|
||||
* @param [in] aMultiLevel false - starts within block are ignored
|
||||
* @return Matched string and various information about the parsing
|
||||
* @retval uint32_t amount of warnings during parser run
|
||||
*
|
||||
* @details
|
||||
* - Parsing done when (match && 0 == aBlockDepth)
|
||||
* - Orphan end markers are ignored and skipped.
|
||||
*/
|
||||
uint32_t regExWorker(char **aOutput, char **aInput, const regex_t *aStart, const regex_t *aEnd, uint8_t *aBlockDepth, bool aMultiLevel)
|
||||
{
|
||||
uint32_t warningCounter = 0;
|
||||
regmatch_t matchStart[2];
|
||||
regmatch_t matchEnd[2];
|
||||
regmatch_t *match = NULL;
|
||||
char *begin = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
if (!**aInput || NULL == *aInput)
|
||||
{
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
xmallocStrlcat(aOutput, " ", 2);
|
||||
}
|
||||
*aInput = NULL;
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
// start
|
||||
if (0 == regexec(aStart, *aInput, 2, matchStart, REG_NOTEOL) && XREGEX_IS_MATCHGROUP(matchStart, 1))
|
||||
{
|
||||
match = matchStart;
|
||||
}
|
||||
|
||||
// end < start
|
||||
if (0 == regexec(aEnd, *aInput, 2, matchEnd, REG_NOTEOL) && XREGEX_IS_MATCHGROUP(matchEnd, 1))
|
||||
{
|
||||
if (match && match->rm_so > matchEnd[1].rm_so)
|
||||
{
|
||||
match = matchEnd;
|
||||
}
|
||||
else if (!match)
|
||||
{
|
||||
match = matchEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
begin = *aInput;
|
||||
size = strlen(*aInput);
|
||||
if (!match)
|
||||
{
|
||||
// complete line within block
|
||||
*aInput += strlen(*aInput);
|
||||
goto regExWorker_end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin = NULL;
|
||||
// no findings
|
||||
if (!match)
|
||||
{
|
||||
// skip remaining character within line without match
|
||||
*aInput += strlen(*aInput);
|
||||
goto regExWorker_end;
|
||||
}
|
||||
}
|
||||
|
||||
if (match == matchStart)
|
||||
{
|
||||
if ((*aBlockDepth && aMultiLevel) || 0 == *aBlockDepth)
|
||||
{
|
||||
DEBUG_LOG_APPEND(2, "[ CEs]");
|
||||
++*aBlockDepth;
|
||||
size = XREGEX_SIZEOF_MATCHGROUP(match, 1);
|
||||
//begin = *aInput + match[1].rm_eo; // don't include start marker in result
|
||||
begin = *aInput + match[1].rm_so; // include start marker in result
|
||||
*aInput += match[1].rm_eo;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ignore starts within block
|
||||
size = match->rm_eo;
|
||||
*aInput += match->rm_eo;
|
||||
}
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
if (match == matchEnd)
|
||||
{
|
||||
DEBUG_LOG_APPEND(2, "[ CEe]");
|
||||
//size = match[1].rm_so; // don't include end marker in result
|
||||
size = match[1].rm_eo; // include end marker in result
|
||||
*aInput += match[1].rm_eo;
|
||||
if (0 < *aBlockDepth)
|
||||
{
|
||||
--*aBlockDepth;
|
||||
}
|
||||
// TODO orphan end markers
|
||||
// must be evaluated depending on expression
|
||||
// e.g. array[]={}; -> must have } and ;
|
||||
// function{} -> must not have ;
|
||||
// else
|
||||
// {
|
||||
// // orphan end marker
|
||||
// ++warningCounter;
|
||||
// }
|
||||
goto regExWorker_end;
|
||||
}
|
||||
|
||||
regExWorker_end:
|
||||
|
||||
if (begin)
|
||||
{
|
||||
xmallocStrlcat(aOutput, begin, size);
|
||||
if (*aBlockDepth)
|
||||
{
|
||||
warningCounter += regExWorker(aOutput, aInput, aStart, aEnd, aBlockDepth, aMultiLevel);
|
||||
}
|
||||
}
|
||||
|
||||
return warningCounter;
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
/*!
|
||||
* @file cfile_parser_worker_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 09.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_PARSER_WORKER_LOC_H_
|
||||
#define STUBSER_CFILE_PARSER_WORKER_LOC_H_
|
||||
|
||||
uint32_t regExWorker(char **aOutput, char **aInput, const regex_t *aStart, const regex_t *aEnd, uint8_t *aBlockDepth, bool aMultiLevel);
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_WORKER_LOC_H_ */
|
||||
/*!
|
||||
* @file cfile_parser_worker_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 09.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFILE_PARSER_WORKER_LOC_H_
|
||||
#define STUBSER_CFILE_PARSER_WORKER_LOC_H_
|
||||
|
||||
uint32_t regExWorker(char **aOutput, char **aInput, const regex_t *aStart, const regex_t *aEnd, uint8_t *aBlockDepth, bool aMultiLevel);
|
||||
|
||||
#endif /* STUBSER_CFILE_PARSER_WORKER_LOC_H_ */
|
||||
|
@@ -1,172 +1,172 @@
|
||||
/*!
|
||||
* @file cfunction.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xtypes.h"
|
||||
#include "xmalloc.h"
|
||||
#include "cfunction_if.h"
|
||||
|
||||
cfunction_t* cfunction_addNewFunction(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfunction_t*) xmalloc(sizeof(cfunction_t));
|
||||
memset(new, 0, sizeof(cfunction_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->amount = 0;
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
cfunction_parameter_t* cfunction_newParameter(cfunction_parameterList_t *aList)
|
||||
{
|
||||
cfunction_parameter_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfunction_parameter_t*) xmalloc(sizeof(cfunction_parameter_t));
|
||||
memset(new, 0, sizeof(cfunction_parameter_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->amount = 0;
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
STATIC int8_t cfunction_freeParameter(struct _CFUNCTION_PARAMETER_LIST_T *aParameter)
|
||||
{
|
||||
cfunction_parameter_t *work = NULL;
|
||||
cfunction_parameter_t *next = NULL;
|
||||
|
||||
if (NULL == aParameter)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aParameter->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
free(work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aParameter->head = NULL;
|
||||
aParameter->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t cfunction_freeFunction(cfunction_t **aFunction)
|
||||
{
|
||||
cfunction_t *work = *aFunction;
|
||||
|
||||
if (NULL == aFunction || NULL == *aFunction)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(work->prefix);
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
cfunction_freeParameter(&work->parameter);
|
||||
free(work);
|
||||
|
||||
*aFunction = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t cfunction_freeList(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *work = NULL;
|
||||
cfunction_t *next = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aList->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
cfunction_freeFunction(&work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aList->head = NULL;
|
||||
aList->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cfunction_printList(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *work = aList->head;
|
||||
cfunction_parameter_t *param = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (work)
|
||||
{
|
||||
param = work->parameter.head;
|
||||
printf("[ cfu]%d:<%s> (%s) %s [%d] ", work->type, work->prefix, work->dataType, work->name, work->parameter.amount);
|
||||
while (param)
|
||||
{
|
||||
printf("%d(%s)%s%s%s", param->type, param->dataType, param->name, (param->array ? param->array : ""), (param->next ? "," : ""));
|
||||
param = param->next;
|
||||
}
|
||||
printf("\n");
|
||||
work = work->next;
|
||||
}
|
||||
printf(" %d Functions\n", aList->amount);
|
||||
}
|
||||
/*!
|
||||
* @file cfunction.c
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xtypes.h"
|
||||
#include "xmalloc.h"
|
||||
#include "cfunction_if.h"
|
||||
|
||||
cfunction_t* cfunction_addNewFunction(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfunction_t*) xmalloc(sizeof(cfunction_t));
|
||||
memset(new, 0, sizeof(cfunction_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->amount = 0;
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
cfunction_parameter_t* cfunction_newParameter(cfunction_parameterList_t *aList)
|
||||
{
|
||||
cfunction_parameter_t *new = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = (cfunction_parameter_t*) xmalloc(sizeof(cfunction_parameter_t));
|
||||
memset(new, 0, sizeof(cfunction_parameter_t));
|
||||
|
||||
if (NULL == aList->head)
|
||||
{
|
||||
aList->amount = 0;
|
||||
aList->head = new;
|
||||
aList->current = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
aList->current->next = new;
|
||||
aList->current = new;
|
||||
}
|
||||
++aList->amount;
|
||||
return new;
|
||||
}
|
||||
|
||||
STATIC int8_t cfunction_freeParameter(struct _CFUNCTION_PARAMETER_LIST_T *aParameter)
|
||||
{
|
||||
cfunction_parameter_t *work = NULL;
|
||||
cfunction_parameter_t *next = NULL;
|
||||
|
||||
if (NULL == aParameter)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aParameter->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
free(work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aParameter->head = NULL;
|
||||
aParameter->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t cfunction_freeFunction(cfunction_t **aFunction)
|
||||
{
|
||||
cfunction_t *work = *aFunction;
|
||||
|
||||
if (NULL == aFunction || NULL == *aFunction)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(work->prefix);
|
||||
free(work->dataType);
|
||||
free(work->name);
|
||||
cfunction_freeParameter(&work->parameter);
|
||||
free(work);
|
||||
|
||||
*aFunction = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t cfunction_freeList(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *work = NULL;
|
||||
cfunction_t *next = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
perror("Null pointer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
work = aList->head;
|
||||
|
||||
while (work)
|
||||
{
|
||||
next = work->next;
|
||||
cfunction_freeFunction(&work);
|
||||
work = next;
|
||||
}
|
||||
|
||||
aList->head = NULL;
|
||||
aList->current = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cfunction_printList(cfunction_list_t *aList)
|
||||
{
|
||||
cfunction_t *work = aList->head;
|
||||
cfunction_parameter_t *param = NULL;
|
||||
|
||||
if (NULL == aList)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (work)
|
||||
{
|
||||
param = work->parameter.head;
|
||||
printf("[ cfu]%d:<%s> (%s) %s [%d] ", work->type, work->prefix, work->dataType, work->name, work->parameter.amount);
|
||||
while (param)
|
||||
{
|
||||
printf("%d(%s)%s%s%s", param->type, param->dataType, param->name, (param->array ? param->array : ""), (param->next ? "," : ""));
|
||||
param = param->next;
|
||||
}
|
||||
printf("\n");
|
||||
work = work->next;
|
||||
}
|
||||
printf(" %d Functions\n", aList->amount);
|
||||
}
|
||||
|
@@ -1,86 +1,86 @@
|
||||
/*!
|
||||
* @file cfunction_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFUNCTION_IF_H_
|
||||
#define STUBSER_CFUNCTION_IF_H_
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CFUNCTION_TYPE_T
|
||||
{
|
||||
CFUNCTION_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CFUNCTION_TYPE_REGULAR = 1, /*!< @brief Regular C function definition */
|
||||
CFUNCTION_TYPE_STATIC = 2, /*!< @brief Static C function definition */
|
||||
CFUNCTION_TYPE_PROTO = 3, /*!< @brief Prototype C function definition */
|
||||
CFUNCTION_TYPE_EXTERN = 4, /*!< @brief External C function definition */
|
||||
CFUNCTION_TYPE_LAST_ENUM
|
||||
} cfunction_type_t;
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CPARAMETER_TYPE_T
|
||||
{
|
||||
CPARAMETER_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CPARAMETER_TYPE_REGULAR = 1, /*!< @brief Regular C function parameter */
|
||||
CPARAMETER_TYPE_FUNCPTR = 2, /*!< @brief Function pointer as parameter */
|
||||
CPARAMETER_TYPE_VARIABLE = 3, /*!< @brief Variable parameter list */
|
||||
CPARAMETER_TYPE_LAST_ENUM
|
||||
} cparameter_type_t;
|
||||
|
||||
/*! @brief Parameter list node */
|
||||
typedef struct _CFUNCTION_PARAMETER_T
|
||||
{
|
||||
cparameter_type_t type; /*!< @brief Parameter type */
|
||||
char* dataType; /*!< @brief data type */
|
||||
char* name; /*!< @brief name */
|
||||
char* array; /*!< @brief array information (e.g. [10] or [DEF_MAX]) */
|
||||
struct _CFUNCTION_PARAMETER_T *next;
|
||||
} cfunction_parameter_t;
|
||||
|
||||
/*! @brief parameter array */
|
||||
typedef struct _CFUNCTION_PARAMETER_LIST_T
|
||||
{
|
||||
uint8_t amount;
|
||||
cfunction_parameter_t *head;
|
||||
cfunction_parameter_t *current;
|
||||
} cfunction_parameterList_t;
|
||||
|
||||
/*! @brief brief_description */
|
||||
typedef struct _CFUNCTION_T
|
||||
{
|
||||
cfunction_type_t type;
|
||||
char *prefix; /*!< @brief prefix like static or extern */
|
||||
char *dataType; /*!< @brief return type */
|
||||
char *name; /*!< @brief name */
|
||||
cfunction_parameterList_t parameter;/*!< @brief parameter array */
|
||||
struct _CFUNCTION_T *next;
|
||||
} cfunction_t;
|
||||
|
||||
/*! @brief Dynamic function list */
|
||||
typedef struct _CFUNCTION_LIST_T
|
||||
{
|
||||
uint16_t amount;
|
||||
cfunction_t *head;
|
||||
cfunction_t *current;
|
||||
} cfunction_list_t;
|
||||
|
||||
#define CFUNCTION_LIST_DEFAULT {\
|
||||
.amount = 0, \
|
||||
.head = NULL, \
|
||||
.current = NULL }
|
||||
|
||||
cfunction_t* cfunction_addNewFunction(cfunction_list_t *aList);
|
||||
cfunction_parameter_t* cfunction_newParameter(cfunction_parameterList_t *aList);
|
||||
int8_t cfunction_freeFunction(cfunction_t **aFunction);
|
||||
int8_t cfunction_freeList(cfunction_list_t *aList);
|
||||
void cfunction_printList(cfunction_list_t *aList);
|
||||
|
||||
#endif /* STUBSER_CFUNCTION_IF_H_ */
|
||||
/*!
|
||||
* @file cfunction_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 28.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_CFUNCTION_IF_H_
|
||||
#define STUBSER_CFUNCTION_IF_H_
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CFUNCTION_TYPE_T
|
||||
{
|
||||
CFUNCTION_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CFUNCTION_TYPE_REGULAR = 1, /*!< @brief Regular C function definition */
|
||||
CFUNCTION_TYPE_STATIC = 2, /*!< @brief Static C function definition */
|
||||
CFUNCTION_TYPE_PROTO = 3, /*!< @brief Prototype C function definition */
|
||||
CFUNCTION_TYPE_EXTERN = 4, /*!< @brief External C function definition */
|
||||
CFUNCTION_TYPE_LAST_ENUM
|
||||
} cfunction_type_t;
|
||||
|
||||
/*! @brief Type of function definition */
|
||||
typedef enum _CPARAMETER_TYPE_T
|
||||
{
|
||||
CPARAMETER_TYPE_UNDEF = 0, /*!< @brief undefined */
|
||||
CPARAMETER_TYPE_REGULAR = 1, /*!< @brief Regular C function parameter */
|
||||
CPARAMETER_TYPE_FUNCPTR = 2, /*!< @brief Function pointer as parameter */
|
||||
CPARAMETER_TYPE_VARIABLE = 3, /*!< @brief Variable parameter list */
|
||||
CPARAMETER_TYPE_LAST_ENUM
|
||||
} cparameter_type_t;
|
||||
|
||||
/*! @brief Parameter list node */
|
||||
typedef struct _CFUNCTION_PARAMETER_T
|
||||
{
|
||||
cparameter_type_t type; /*!< @brief Parameter type */
|
||||
char* dataType; /*!< @brief data type */
|
||||
char* name; /*!< @brief name */
|
||||
char* array; /*!< @brief array information (e.g. [10] or [DEF_MAX]) */
|
||||
struct _CFUNCTION_PARAMETER_T *next;
|
||||
} cfunction_parameter_t;
|
||||
|
||||
/*! @brief parameter array */
|
||||
typedef struct _CFUNCTION_PARAMETER_LIST_T
|
||||
{
|
||||
uint8_t amount;
|
||||
cfunction_parameter_t *head;
|
||||
cfunction_parameter_t *current;
|
||||
} cfunction_parameterList_t;
|
||||
|
||||
/*! @brief brief_description */
|
||||
typedef struct _CFUNCTION_T
|
||||
{
|
||||
cfunction_type_t type;
|
||||
char *prefix; /*!< @brief prefix like static or extern */
|
||||
char *dataType; /*!< @brief return type */
|
||||
char *name; /*!< @brief name */
|
||||
cfunction_parameterList_t parameter;/*!< @brief parameter array */
|
||||
struct _CFUNCTION_T *next;
|
||||
} cfunction_t;
|
||||
|
||||
/*! @brief Dynamic function list */
|
||||
typedef struct _CFUNCTION_LIST_T
|
||||
{
|
||||
uint16_t amount;
|
||||
cfunction_t *head;
|
||||
cfunction_t *current;
|
||||
} cfunction_list_t;
|
||||
|
||||
#define CFUNCTION_LIST_DEFAULT {\
|
||||
.amount = 0, \
|
||||
.head = NULL, \
|
||||
.current = NULL }
|
||||
|
||||
cfunction_t* cfunction_addNewFunction(cfunction_list_t *aList);
|
||||
cfunction_parameter_t* cfunction_newParameter(cfunction_parameterList_t *aList);
|
||||
int8_t cfunction_freeFunction(cfunction_t **aFunction);
|
||||
int8_t cfunction_freeList(cfunction_list_t *aList);
|
||||
void cfunction_printList(cfunction_list_t *aList);
|
||||
|
||||
#endif /* STUBSER_CFUNCTION_IF_H_ */
|
||||
|
@@ -1,19 +1,19 @@
|
||||
/*!
|
||||
* @file stubser_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_STUBSER_IF_H_
|
||||
#define STUBSER_STUBSER_IF_H_
|
||||
|
||||
int stubser_createStub(char *path, char* aNoSuffix, char *aOutput);
|
||||
|
||||
#endif /* STUBSER_STUBSER_IF_H_ */
|
||||
/*!
|
||||
* @file stubser_if.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 27.02.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_STUBSER_IF_H_
|
||||
#define STUBSER_STUBSER_IF_H_
|
||||
|
||||
int stubser_createStub(char *path, char* aNoSuffix, char *aOutput);
|
||||
|
||||
#endif /* STUBSER_STUBSER_IF_H_ */
|
||||
|
@@ -1,76 +1,76 @@
|
||||
/*!
|
||||
* @file stubser_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 04.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_STUBSER_LOC_H_
|
||||
#define STUBSER_STUBSER_LOC_H_
|
||||
|
||||
#define NEWLINES "\r\n"
|
||||
#define NEWLINE(output) fputs(NEWLINES, output)
|
||||
#define NCHECK(string) (NULL == string ? "" : string)
|
||||
|
||||
// Maximum amount of instances within test subject functions
|
||||
#define STUB_INSTANCES_AMOUNT 32
|
||||
|
||||
#define STUB_START_S1 "// ---------------------------------------------->" NEWLINES \
|
||||
"/* Start of stub %s() */"
|
||||
#define STUB_END_S1 "/* End of stub %s() */" NEWLINES \
|
||||
"// ----------------------------------------------<%s"
|
||||
|
||||
#define STUBINSTANCE_AMOUNT_S1 "STUB_INSTANCES_AMOUNT_%s" //STUB_INSTANCES_AMOUNT_modulfunction_1
|
||||
#define STUBPARAMETER_TYPEDEF_S1 "stubparameter_t_%s" // stubparameter_t_modulfunction_1
|
||||
#define STUBPARAMETER_STRUCT_S1 "stubparameter_%s" // stubparameter_modulfunction_1
|
||||
#define STUBPARAMETER_PARAM_S1 "parameter_%c" // "stubparameter_modulfunction_1".parameter_a
|
||||
#define STUBPARAMETER_CALLTEST_S "stubCallTest"
|
||||
#define STUBPARAMETER_POINTERHANDLING_S "stubPointerHandling"
|
||||
#define STUBPARAMETER_POINTERHANDLING_ENUM_S "stub_parameter_pointer_handling_t"
|
||||
#define STUBPARAMETER_POINTERHANDLING_ADDRESS_S "STUB_PARAMETER_POINTER_HANDLING_ADDRESS"
|
||||
#define STUBPARAMETER_POINTERHANDLING_CONTENT_S "STUB_PARAMETER_POINTER_HANDLING_CONTENT"
|
||||
#define STUBPARAMETER_POINTERHANDLING_INJECT_S "STUB_PARAMETER_POINTER_HANDLING_INJECT"
|
||||
#define STUBPARAMETER_RETURN_S "returnValue" // "stubparameter_modulfunction_1".returnValue
|
||||
#define STUBINSTANCE_S1 "stubInstance_%s" // stubInstance_modulfunction_1
|
||||
#define STUBINSTANCE_DATATYPE_S "uint8_t"
|
||||
#define STUBINIT_PARAM_INSTANCE_S "aInstance"
|
||||
#define STUBINIT_PARAM_CALLTEST_S "aStubCallTest"
|
||||
#define STUBINIT_PARAM_PARAMETER_S1 "aParameter_%c" // aParameter_a
|
||||
#define STUBINIT_PARAM_RETURN_S "aReturnValue"
|
||||
#define STUBINIT_PARAM_POINTERHANDLING_S "aPointerHandling"
|
||||
|
||||
#define STUBDEFAULT_PARAMETER_INDEX_CHAR 'a'
|
||||
#define STUBDEFAULT_VALUE_FUNCTIONPOINTER_S "0xAA"
|
||||
#define STUBDEFAULT_VALUE_POINTER_S1 "%s_testData" // stubfilename_testData
|
||||
#define STUBDEFAULT_VALUE_POINTERSIZE_S "1"
|
||||
#define STUBDEFAULT_VALUE_VARIABLE_S "0xAA"
|
||||
|
||||
#define STUBFUNCTION_USER_INITEXPECTED_S1 "stub_%s_user_initExpected" // stub_testfunction_initExpected
|
||||
#define STUBFUNCTION_USER_INITGLOBALS_S1 "stub_%s_user_initGlobals" // stub_testfunction_initGlobals
|
||||
#define STUBFUNCTION_USER_CHECK_S1 "stub_%s_user_checkGlobals" // stub_testfunction_checkGlobals
|
||||
|
||||
#define STUBFUNCTION_INITEXPECTED_S1 "stub_%s_initExpected" // stub_testfunction_initExpected
|
||||
#define STUBFUNCTION_INITGLOBALS_S1 "stub_%s_initGlobals" // stub_testfunction_initGlobals
|
||||
#define STUBFUNCTION_CHECK_S1 "stub_%s_checkGlobals" // stub_testfunction_checkGlobals
|
||||
#define STUBFUNCTION_INIT_S1 "stub_%s_init" // stub_testfunction_init
|
||||
#define STUBVARIABLE_EXPECTED_S1 "%s_expected" // variable_expected
|
||||
|
||||
#define STUB_CONSOLE_GOBACK "\033[2K\r"
|
||||
#define STUB_CONSOLE_RUN "[ ]"
|
||||
#define STUB_CONSOLE_OK "[ OK ]"
|
||||
#define STUB_CONSOLE_WARN "[WARN]"
|
||||
#define STUB_CONSOLE_FAIL "[FAIL]"
|
||||
#define STUB_CONSOLE_PARSE_ERROR_S2 "\n" STUB_CONSOLE_WARN " %s parsing with %d warnings (check output manually)"
|
||||
#define STUB_CONSOLE_PARSE_RUN_S1 STUB_CONSOLE_RUN " %s parsing..."
|
||||
#define STUB_CONSOLE_PARSE_OK_S1 STUB_CONSOLE_GOBACK STUB_CONSOLE_OK " %s parsing..."
|
||||
#define STUB_CONSOLE_CREATE_ERROR_S2 "...stub creation failed\n"STUB_CONSOLE_FAIL " %s creation failed (%d)\n"
|
||||
#define STUB_CONSOLE_CREATE_OK_S1 "...stub created > %s\n"
|
||||
|
||||
#define STUB_REGEX_STD_DATATYPE "(^|[^_[:alnum:]])([ui]+nt[0-9]{1,2}_t|char|uchar|word[12346]{2}|int[12346]{0,2}|byte)([^_[:alnum:]]|$)"
|
||||
#endif /* STUBSER_STUBSER_LOC_H_ */
|
||||
/*!
|
||||
* @file stubser_loc.h
|
||||
* @brief
|
||||
* @details
|
||||
* Project: \n
|
||||
* Subsystem: \n
|
||||
* Module: \n
|
||||
* Code: GNU-C\n
|
||||
*
|
||||
* @date 04.03.2017
|
||||
* @author Martin Winkler
|
||||
*/
|
||||
|
||||
#ifndef STUBSER_STUBSER_LOC_H_
|
||||
#define STUBSER_STUBSER_LOC_H_
|
||||
|
||||
#define NEWLINES "\r\n"
|
||||
#define NEWLINE(output) fputs(NEWLINES, output)
|
||||
#define NCHECK(string) (NULL == string ? "" : string)
|
||||
|
||||
// Maximum amount of instances within test subject functions
|
||||
#define STUB_INSTANCES_AMOUNT 32
|
||||
|
||||
#define STUB_START_S1 "// ---------------------------------------------->" NEWLINES \
|
||||
"/* Start of stub %s() */"
|
||||
#define STUB_END_S1 "/* End of stub %s() */" NEWLINES \
|
||||
"// ----------------------------------------------<%s"
|
||||
|
||||
#define STUBINSTANCE_AMOUNT_S1 "STUB_INSTANCES_AMOUNT_%s" //STUB_INSTANCES_AMOUNT_modulfunction_1
|
||||
#define STUBPARAMETER_TYPEDEF_S1 "stubparameter_t_%s" // stubparameter_t_modulfunction_1
|
||||
#define STUBPARAMETER_STRUCT_S1 "stubparameter_%s" // stubparameter_modulfunction_1
|
||||
#define STUBPARAMETER_PARAM_S1 "parameter_%c" // "stubparameter_modulfunction_1".parameter_a
|
||||
#define STUBPARAMETER_CALLTEST_S "stubCallTest"
|
||||
#define STUBPARAMETER_POINTERHANDLING_S "stubPointerHandling"
|
||||
#define STUBPARAMETER_POINTERHANDLING_ENUM_S "stub_parameter_pointer_handling_t"
|
||||
#define STUBPARAMETER_POINTERHANDLING_ADDRESS_S "STUB_PARAMETER_POINTER_HANDLING_ADDRESS"
|
||||
#define STUBPARAMETER_POINTERHANDLING_CONTENT_S "STUB_PARAMETER_POINTER_HANDLING_CONTENT"
|
||||
#define STUBPARAMETER_POINTERHANDLING_INJECT_S "STUB_PARAMETER_POINTER_HANDLING_INJECT"
|
||||
#define STUBPARAMETER_RETURN_S "returnValue" // "stubparameter_modulfunction_1".returnValue
|
||||
#define STUBINSTANCE_S1 "stubInstance_%s" // stubInstance_modulfunction_1
|
||||
#define STUBINSTANCE_DATATYPE_S "uint8_t"
|
||||
#define STUBINIT_PARAM_INSTANCE_S "aInstance"
|
||||
#define STUBINIT_PARAM_CALLTEST_S "aStubCallTest"
|
||||
#define STUBINIT_PARAM_PARAMETER_S1 "aParameter_%c" // aParameter_a
|
||||
#define STUBINIT_PARAM_RETURN_S "aReturnValue"
|
||||
#define STUBINIT_PARAM_POINTERHANDLING_S "aPointerHandling"
|
||||
|
||||
#define STUBDEFAULT_PARAMETER_INDEX_CHAR 'a'
|
||||
#define STUBDEFAULT_VALUE_FUNCTIONPOINTER_S "0xAA"
|
||||
#define STUBDEFAULT_VALUE_POINTER_S1 "%s_testData" // stubfilename_testData
|
||||
#define STUBDEFAULT_VALUE_POINTERSIZE_S "1"
|
||||
#define STUBDEFAULT_VALUE_VARIABLE_S "0xAA"
|
||||
|
||||
#define STUBFUNCTION_USER_INITEXPECTED_S1 "stub_%s_user_initExpected" // stub_testfunction_initExpected
|
||||
#define STUBFUNCTION_USER_INITGLOBALS_S1 "stub_%s_user_initGlobals" // stub_testfunction_initGlobals
|
||||
#define STUBFUNCTION_USER_CHECK_S1 "stub_%s_user_checkGlobals" // stub_testfunction_checkGlobals
|
||||
|
||||
#define STUBFUNCTION_INITEXPECTED_S1 "stub_%s_initExpected" // stub_testfunction_initExpected
|
||||
#define STUBFUNCTION_INITGLOBALS_S1 "stub_%s_initGlobals" // stub_testfunction_initGlobals
|
||||
#define STUBFUNCTION_CHECK_S1 "stub_%s_checkGlobals" // stub_testfunction_checkGlobals
|
||||
#define STUBFUNCTION_INIT_S1 "stub_%s_init" // stub_testfunction_init
|
||||
#define STUBVARIABLE_EXPECTED_S1 "%s_expected" // variable_expected
|
||||
|
||||
#define STUB_CONSOLE_GOBACK "\033[2K\r"
|
||||
#define STUB_CONSOLE_RUN "[ ]"
|
||||
#define STUB_CONSOLE_OK "[ OK ]"
|
||||
#define STUB_CONSOLE_WARN "[WARN]"
|
||||
#define STUB_CONSOLE_FAIL "[FAIL]"
|
||||
#define STUB_CONSOLE_PARSE_ERROR_S2 "\n" STUB_CONSOLE_WARN " %s parsing with %d warnings (check output manually)"
|
||||
#define STUB_CONSOLE_PARSE_RUN_S1 STUB_CONSOLE_RUN " %s parsing..."
|
||||
#define STUB_CONSOLE_PARSE_OK_S1 STUB_CONSOLE_GOBACK STUB_CONSOLE_OK " %s parsing..."
|
||||
#define STUB_CONSOLE_CREATE_ERROR_S2 "...stub creation failed\n"STUB_CONSOLE_FAIL " %s creation failed (%d)\n"
|
||||
#define STUB_CONSOLE_CREATE_OK_S1 "...stub created > %s\n"
|
||||
|
||||
#define STUB_REGEX_STD_DATATYPE "(^|[^_[:alnum:]])([ui]+nt[0-9]{1,2}_t|char|uchar|word[12346]{2}|int[12346]{0,2}|byte)([^_[:alnum:]]|$)"
|
||||
#endif /* STUBSER_STUBSER_LOC_H_ */
|
||||
|
Reference in New Issue
Block a user