]> pilppa.org Git - libplp.git/commitdiff
api fixes and cleanups
authorMika Laitio <lamikr@pilppa.org>
Fri, 3 Aug 2012 15:41:41 +0000 (18:41 +0300)
committerMika Laitio <lamikr@pilppa.org>
Fri, 3 Aug 2012 15:41:41 +0000 (18:41 +0300)
cleaned up the configuration data file
handling via libuci.

Signed-off-by: Mika Laitio <lamikr@pilppa.org>
25 files changed:
.cproject
.settings/language.settings.xml [new file with mode: 0644]
src/DataReader.cc
src/DataReader.hh
src/DataSummary.cc [new file with mode: 0644]
src/DataSummary.hh [new file with mode: 0644]
src/Device.cc
src/DeviceConfig.cc
src/DeviceConfig.hh
src/FileUtil.cc
src/FileUtil.hh
src/Makefile.am
src/StoreCache.cc
src/StoreDay.cc
src/config.c
src/config.h
src/private/uci_config.c [new file with mode: 0644]
src/private/uci_config.h [new file with mode: 0644]
src/str_util.c
src/str_util.h
src_test/Makefile.am
src_test/test_config.c [deleted file]
src_test/test_config1.c [new file with mode: 0644]
src_test/test_config2.c [deleted file]
src_test/test_config2.cc [new file with mode: 0644]

index 8ca237c5832560c0f4a457e8cf38de0f3f3a239b..2fdfaa98acd7cf29926aa4e7d7cc4295506e9bbc 100644 (file)
--- a/.cproject
+++ b/.cproject
                                        </folderInfo>
                                </configuration>
                        </storageModule>
-                       <storageModule moduleId="scannerConfiguration">
-                               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
-                               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="makefileGenerator">
-                                               <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.191751922;cdt.managedbuild.tool.gnu.c.compiler.input.1709560994">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1122819763;cdt.managedbuild.tool.gnu.cpp.compiler.input.1654014351">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1688000519;cdt.managedbuild.tool.gnu.c.compiler.input.787411291">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.544771650;cdt.managedbuild.tool.gnu.cpp.compiler.input.1106468633">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                       </storageModule>
                        <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
                </cconfiguration>
                <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.480827115">
                                        </folderInfo>
                                </configuration>
                        </storageModule>
-                       <storageModule moduleId="scannerConfiguration">
-                               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
-                               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="makefileGenerator">
-                                               <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                       <buildOutputProvider>
-                                               <openAction enabled="true" filePath=""/>
-                                               <parser enabled="true"/>
-                                       </buildOutputProvider>
-                                       <scannerInfoProvider id="specsFile">
-                                               <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                               <parser enabled="true"/>
-                                       </scannerInfoProvider>
-                               </profile>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.191751922;cdt.managedbuild.tool.gnu.c.compiler.input.1709560994">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1122819763;cdt.managedbuild.tool.gnu.cpp.compiler.input.1654014351">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1688000519;cdt.managedbuild.tool.gnu.c.compiler.input.787411291">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.544771650;cdt.managedbuild.tool.gnu.cpp.compiler.input.1106468633">
-                                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="makefileGenerator">
-                                                       <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-                                               <buildOutputProvider>
-                                                       <openAction enabled="true" filePath=""/>
-                                                       <parser enabled="true"/>
-                                               </buildOutputProvider>
-                                               <scannerInfoProvider id="specsFile">
-                                                       <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
-                                                       <parser enabled="true"/>
-                                               </scannerInfoProvider>
-                                       </profile>
-                               </scannerConfigBuildInfo>
-                       </storageModule>
                        <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
                </cconfiguration>
        </storageModule>
        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
                <project id="libplp.cdt.managedbuild.target.gnu.exe.707002465" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
        </storageModule>
+       <storageModule moduleId="refreshScope" versionNumber="2">
+               <configuration configurationName="Release">
+                       <resource resourceType="PROJECT" workspacePath="/libplp"/>
+               </configuration>
+               <configuration configurationName="Debug">
+                       <resource resourceType="PROJECT" workspacePath="/libplp"/>
+               </configuration>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+                       <buildOutputProvider>
+                               <openAction enabled="true" filePath=""/>
+                               <parser enabled="true"/>
+                       </buildOutputProvider>
+                       <scannerInfoProvider id="specsFile">
+                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                               <parser enabled="true"/>
+                       </scannerInfoProvider>
+               </profile>
+               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+                       <buildOutputProvider>
+                               <openAction enabled="true" filePath=""/>
+                               <parser enabled="true"/>
+                       </buildOutputProvider>
+                       <scannerInfoProvider id="specsFile">
+                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                               <parser enabled="true"/>
+                       </scannerInfoProvider>
+               </profile>
+               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+                       <buildOutputProvider>
+                               <openAction enabled="true" filePath=""/>
+                               <parser enabled="true"/>
+                       </buildOutputProvider>
+                       <scannerInfoProvider id="specsFile">
+                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+                               <parser enabled="true"/>
+                       </scannerInfoProvider>
+               </profile>
+               <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+                       <buildOutputProvider>
+                               <openAction enabled="true" filePath=""/>
+                               <parser enabled="true"/>
+                       </buildOutputProvider>
+                       <scannerInfoProvider id="specsFile">
+                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+                               <parser enabled="true"/>
+                       </scannerInfoProvider>
+               </profile>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.191751922;cdt.managedbuild.tool.gnu.c.compiler.input.1709560994">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.480827115;cdt.managedbuild.config.gnu.exe.release.480827115.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1122819763;cdt.managedbuild.tool.gnu.cpp.compiler.input.1654014351">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1688000519;cdt.managedbuild.tool.gnu.c.compiler.input.787411291">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1645946346;cdt.managedbuild.config.gnu.exe.debug.1645946346.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.544771650;cdt.managedbuild.tool.gnu.cpp.compiler.input.1106468633">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+                       <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+                               <buildOutputProvider>
+                                       <openAction enabled="true" filePath=""/>
+                                       <parser enabled="true"/>
+                               </buildOutputProvider>
+                               <scannerInfoProvider id="specsFile">
+                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+                                       <parser enabled="true"/>
+                               </scannerInfoProvider>
+                       </profile>
+               </scannerConfigBuildInfo>
+       </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+       <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
 </cproject>
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
new file mode 100644 (file)
index 0000000..8766d20
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+       <configuration id="cdt.managedbuild.config.gnu.exe.debug.1645946346" name="Debug">
+               <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+                       <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+                       <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+               </extension>
+       </configuration>
+       <configuration id="cdt.managedbuild.config.gnu.exe.release.480827115" name="Release">
+               <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+                       <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+                       <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+               </extension>
+       </configuration>
+</project>
index 00f861a61dc116907712e6e8bb10ac7c52ca4492..00fc1f4da9f1d0462eb5bf77acc9fc4949951fc8 100644 (file)
@@ -35,12 +35,13 @@ DataReader::DataReader(string device_id_param) {
        string  base_dir;
 
        log_debug("device_id: %s\n", device_id_param.c_str());
-       device_config   = NULL;
-       device_id       = device_id_param;
-       base_dir        = DeviceConfig::get_base_dir_name();
-       device_dir      = FileUtil::concat_paths(base_dir, device_id);
-       device_ch_dir   = FileUtil::concat_paths(base_dir, "cache");
-       device_ch_dir   = FileUtil::concat_paths(device_ch_dir, device_id);
+       summary_calc_type       = MEAN;
+       device_config           = NULL;
+       device_id               = device_id_param;
+       base_dir                = DeviceConfig::get_base_dir_name();
+       device_dir              = FileUtil::concat_paths(base_dir, device_id);
+       device_ch_dir           = FileUtil::concat_paths(base_dir, "cache");
+       device_ch_dir           = FileUtil::concat_paths(device_ch_dir, device_id);
 }
 
 DataReader::~DataReader() {
@@ -447,14 +448,15 @@ string DataReader::get_device_id() {
  * @rerurn string representing device type.
  * In the case of error, an empty string is returned.
  */
-string DataReader::get_device_type() {
-       string  ret_val;
+bool DataReader::get_device_type(string& type_param) {
+       bool    ret_val;
 
+       ret_val = false;
        if (device_config == NULL) {
                device_config   = DeviceConfig::get_device_config(device_id);
        }
        if (device_config != NULL) {
-               ret_val = device_config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+               ret_val = device_config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, type_param);
        }
        return ret_val;
 }
index 23a39d3912ec43afa02657838da46477d2e146f8..b544242bf39e76b1fd272b9cae6a7f00f82329de 100644 (file)
@@ -60,7 +60,7 @@ namespace plp {
 
                        DataRange *get_data(Date *start_date, Date *end_date);
                        std::string get_device_id();
-                       std::string get_device_type();
+                       bool get_device_type(std::string& type_param);
                        Data *get_latest_data();
                protected:
                        std::string                     device_id;
diff --git a/src/DataSummary.cc b/src/DataSummary.cc
new file mode 100644 (file)
index 0000000..5c91ba1
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * DataSummary.cc
+ *
+ *  Created on: Aug 3, 2012
+ *      Author: lamikr
+ */
+
+#include "DataSummary.hh"
+
+DataSummary::DataSummary()
+{
+       // TODO Auto-generated constructor stub
+
+}
+
+DataSummary::~DataSummary()
+{
+       // TODO Auto-generated destructor stub
+}
+
+string DataSummary::get_summary_period_name(enum EnumSummaryPeriod period_param) {
+       string ret_val;
+
+       switch(period_param) {
+               case PERIOD_YEARLY:
+                       ret_val = "yearly";
+                       break;
+               case PERIOD_MONTHLY:
+                       ret_val = "monthly";
+                       break;
+               case PERIOD_DAILY:
+                       ret_val = "daily";
+                       break;
+               case PERIOD_HOURLY:
+                       ret_val = "hourly";
+                       break;
+               case PERIOD_MINUTELY:
+                       ret_val = "minutely";
+                       break;
+               case PERIOD_SECONDLY:
+                       ret_val = "secondly";
+                       break;
+               default:
+                       ret_val = "daily";
+                       break;
+       }
+       return ret_val;
+
+}
+
+string DataSummary::get_summary_calculation_name(enum EnumSummaryCalculationType type_param) {
+       string ret_val;
+
+       switch(type_param) {
+               case SUM:
+                       ret_val = "sum";
+                       break;
+               case DELTA:
+                       ret_val = "delta";
+                       break;
+               case MIN:
+                       ret_val = "min";
+                       break;
+               case MAX:
+                       ret_val = "max";
+                       break;
+               case MEAN:
+                       ret_val = "mean";
+                       break;
+               default:
+                       ret_val = "sum";
+                       break;
+       }
+       return ret_val;
+}
+
diff --git a/src/DataSummary.hh b/src/DataSummary.hh
new file mode 100644 (file)
index 0000000..3b08761
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * DataSummary.hh
+ *
+ *  Created on: Aug 3, 2012
+ *      Author: lamikr
+ */
+
+#ifndef DATASUMMARY_HH_
+#define DATASUMMARY_HH_
+
+#include <string>
+
+extern "C" {
+       #include <uci.h>
+       #include <stdbool.h>
+}
+
+using namespace std;
+
+enum EnumSummaryPeriod{PERIOD_YEARLY, PERIOD_MONTHLY, PERIOD_DAILY, PERIOD_HOURLY, PERIOD_MINUTELY, PERIOD_SECONDLY};
+enum EnumSummaryCalculationType {SUM, DELTA, MIN, MAX, MEAN};
+
+class DataSummary {
+       public:
+               DataSummary();
+               virtual ~DataSummary();
+               std::string             device_id;
+               static std::string get_summary_period_name(enum EnumSummaryPeriod period_param);
+               static std::string get_summary_calculation_name(enum EnumSummaryCalculationType type_param);
+};
+
+#endif /* DATASUMMARY_HH_ */
index d583f16199dd95670c450608dc3a2dbd603cc338..714e830e13bcbafdda786fa10522e6339f544220 100644 (file)
 using namespace std;
 using namespace plp;
 
-Device::Device(string id_param, string type_param) {
+Device::Device(string id_param,
+               string type_param) {
        id                      = id_param;
        type                    = type_param;
        lifecycle_status        = LIFECYCLE_STATUS__UNAVAILABLE;
 }
 
-Device::Device(std::string id_param, std::string type_param, std::string name_param, plp::EnumDeviceLifeCycleStatus status_param) {
+Device::Device(std::string id_param,
+               string type_param,
+               string name_param,
+               plp::EnumDeviceLifeCycleStatus status_param) {
        id                      = id_param;
        type                    = type_param;
        name                    = name_param;
index 66fe863be28c17766269f3203c88807d46ade757..75af9f396579b0adad82b6ce9144120a6c88d473 100644 (file)
 #include <string.h>
 #include <malloc.h>
 
-#include "log.h"
-
 #include "DataReader.hh"
 #include "FileUtil.hh"
 
+#include "log.h"
+#include "config.h"
+#include "private/uci_config.h"
+
 using namespace std;
 using namespace plp;
 
@@ -38,144 +40,16 @@ ConfigHandle::~ConfigHandle() {
        free(full_fname);
 }
 
-static int uci_create_named_section(ConfigHandle *cfg_handle,
-                               const char *section_type,
-                               const char *section_name,
-                               bool save_immediately)
-{
-       struct uci_ptr  ptr;
-       int             ret_val;
-       char            *cmd_dta;
-       int             len;
-
-       ret_val = -1;
-       if ((cfg_handle != NULL) &&
-           (cfg_handle->_ctx != NULL) &&
-           (cfg_handle->short_fname != NULL) &&
-           (cfg_handle->full_fname != NULL) &&
-           (section_type != NULL) &&
-           (section_name != NULL)) {
-               len     = strlen(cfg_handle->short_fname);
-               len     = len + 1;
-               len     = len + strlen(section_type);
-               len     = len + 1;
-               len     = len + strlen(section_name);
-               len     = len + 1;
-               cmd_dta = (char *)malloc(len);
-               if (cmd_dta != NULL) {
-                       snprintf(cmd_dta,
-                               len,
-                               "%s.%s=%s",
-                               cfg_handle->short_fname,
-                               section_name,
-                               section_type);
-                       if (uci_lookup_ptr(cfg_handle->_ctx, &ptr, cmd_dta, true) == UCI_OK) {
-                               ret_val = uci_set(cfg_handle->_ctx, &ptr);
-                               if (ret_val == UCI_OK) {
-                                       if (save_immediately) {
-                                               ret_val = uci_save(cfg_handle->_ctx, ptr.p);
-                                       }
-                               }
-                       }
-                       free(cmd_dta);
-               }
-       }
-       return ret_val;
-}
-
-static bool set_config_value_to_section(ConfigHandle *cfg_handle,
-                       const char *section_type,
-                       const char *section_name,
-                       const char *key,
-                       const char *value) {
-       struct uci_section      *sct;
-       struct uci_section      *tmp_sct;
-       int                     err_flg;
-       struct uci_element      *elem;
-       struct uci_ptr          ptr;
-       bool                    ret_val;
-
-       ret_val = false;
-       err_flg = UCI_OK;
-       if ((cfg_handle != NULL) &&
-           (cfg_handle->_ctx != NULL) &&
-           (cfg_handle->_pkg != NULL) &&
-           (section_type != NULL) &&
-           (section_name != NULL) &&
-           (key != NULL) &&
-           (value != NULL)) {
-               sct     = NULL;
-               uci_foreach_element(&cfg_handle->_pkg->sections, elem) {
-                       tmp_sct = uci_to_section(elem);
-                       if (strcmp(tmp_sct->type, section_type) == 0) {
-                               sct     = tmp_sct;
-                               break;
-                       }
-               }
-               if (sct == NULL) {
-                       log_debug("Creating new section %s to configuration file: %s\n", section_name, cfg_handle->full_fname);
-                       //err_flg       = uci_add_named_section(ctx, pkg, section_type, section_name, &sct);
-                       //err_flg       = uci_add_section(ctx, pkg, section_name, &sct);
-                       err_flg = uci_create_named_section(cfg_handle,
-                                               section_type,
-                                               section_name,
-                                               false);
-                       if (err_flg == UCI_OK) {
-                               uci_foreach_element(&cfg_handle->_pkg->sections, elem) {
-                                       tmp_sct = uci_to_section(elem);
-                                       if (strcmp(tmp_sct->type, section_type) == 0) {
-                                               sct     = tmp_sct;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               if (err_flg == UCI_OK) {
-                       memset(&ptr, 0, sizeof(ptr));
-                       ptr.package     = cfg_handle->_pkg->e.name;
-                       ptr.section     = sct->e.name;
-                       ptr.option      = key;
-                       err_flg         = uci_lookup_ptr(cfg_handle->_ctx, &ptr, NULL, false);
-                       if (err_flg == UCI_OK) {
-                               ptr.value       = value;
-                               err_flg         = uci_set(cfg_handle->_ctx, &ptr);
-                               if (err_flg == UCI_OK) {
-                                       err_flg = uci_save(cfg_handle->_ctx, cfg_handle->_pkg);
-                                       if (err_flg == UCI_OK) {
-                                               ret_val = true;
-                                               log_debug("Set value to section %s in configuration file: %s\n", section_name, cfg_handle->full_fname);
-                                       }
-                                       else {
-                                               log_error("Failed to set value to configuration file: %s\n. Could not save the file\n", cfg_handle->full_fname);
-                                       }
-                               }
-                               else {
-                                       log_error("Failed to set value to configuration file: %s\n. Could not set new value\n", cfg_handle->full_fname);
-                               }
-                       }
-                       else {
-                               log_error("Failed to set value to configuration file: %s\n. Could not look-up pointer for package %s section %s.\n",
-                                       cfg_handle->full_fname,
-                                       cfg_handle->_pkg->e.name,
-                                       sct->e.name);
-                       }
-                       uci_free_context(cfg_handle->_ctx);
-               }
-               else {
-                       log_error("Failed to set value to configuration file: %s. Could not create section %s.\n", cfg_handle->full_fname, section_name);
-               }
-       }
-       else {
-               log_error("Failed to set value to configuration file, invalid parameters\n");
-       }
-       return ret_val;
-}
-
 DeviceConfig::DeviceConfig(string device_id_param) {
+       bool    succ;
+
        device_id       = device_id_param;
        uci_handle      = load_device_config(device_id_param);
        if (uci_handle != NULL) {
-               device_type     = get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+               succ    = get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, device_type);
+               if (succ == false) {
+                       log_error("Could not read device type from the configuration file.\n");
+               }
        }
        else {
                log_error("Could not read device configuration.\n");
@@ -183,7 +57,14 @@ DeviceConfig::DeviceConfig(string device_id_param) {
 }
 
 DeviceConfig::~DeviceConfig() {
+       bool    suc;
+
        if (uci_handle != NULL) {
+               suc     = uci_save_config_values(uci_handle->_ctx,
+                                       uci_handle->_pkg);
+               if (suc == true) {
+                       log_debug("saved the configuration file: %s\n", uci_handle->full_fname);
+               }
                delete(uci_handle);
                uci_handle      = NULL;
        }
@@ -215,130 +96,154 @@ string DeviceConfig::get_base_dir_name() {
        return store_base_dir;
 }
 
-string DeviceConfig::get_dir_name(string device_id_param) {
+string DeviceConfig::get_config_path_name() {
        string  ret_val;
-       string  d_name;
+       string  path_name;
 
-       d_name  = DeviceConfig::get_base_dir_name();
-       ret_val = FileUtil::concat_paths(d_name, device_id_param);
+       path_name       = DeviceConfig::get_base_dir_name();
+       ret_val         = FileUtil::concat_paths(path_name, device_id);
        return ret_val;
 }
 
-string DeviceConfig::get_file_name(string device_id_param) {
+string DeviceConfig::get_config_file_name() {
        string  ret_val;
-       string  fname;
+       string  fname_base;
 
-       fname   = DEVICE_CONFIG__FILE_NAME;
-       ret_val = get_dir_name(device_id_param);
-       ret_val = FileUtil::concat_paths(ret_val, fname);
+       fname_base      = DEVICE_CONFIG__FILE_NAME;
+       ret_val         = get_config_path_name();
+       ret_val         = FileUtil::concat_paths(ret_val, fname_base);
        return ret_val;
 }
 
-string DeviceConfig::get_config_value(string key) {
-       struct uci_section      *section;
-       struct uci_option       *option;
-       string                  ret_val;
+string DeviceConfig::get_pathless_config_file_name() {
+       return DEVICE_CONFIG__FILE_NAME;
+}
 
-       if (uci_handle != NULL) {
-               section = uci_lookup_section(uci_handle->_ctx,
-                                       uci_handle->_pkg,
-                                       DEVICE_CONFIG__SECTION_NAME);
-               if (section != NULL) {
-                       option  = uci_lookup_option(uci_handle->_ctx, section, key.c_str());
-                       if (option != NULL) {
-                               switch (option->type) {
-                                       case UCI_TYPE_STRING:
-                                               //log_info("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string);
-                                               ret_val = option->v.string;
-                                               break;
-                                       default:
-                                               log_error("key: %s Failed to read parameter value\n", key.c_str());
-                                               break;
-                               }
-                       }
-                       else {
-                               log_error("key: %s Failed to read parameter value\n", key.c_str());
+bool DeviceConfig::get_config_value(string key, string& value) {
+       char    *ret;
+       bool    ret_val;
+
+       ret_val = false;
+       value.clear();
+       if ((uci_handle != NULL) &&
+           (uci_handle->_ctx != NULL) &&
+           (uci_handle->_pkg != NULL)) {
+               if (key.empty() == false) {
+                       ret     = uci_get_config_value(uci_handle->_ctx,
+                                               uci_handle->_pkg,
+                                               DEVICE_CONFIG__SECTION_NAME,
+                                               key.c_str());
+                       if (ret != NULL) {
+                               ret_val = true;
+                               value   = ret;
                        }
                }
+               else {
+                       log_error("Failed to read configuration value, key was empty string.\n");
+               }
+       }
+       else {
+               log_error("Failed to read configuration value for key: %s. Invalid handle to configuration file.\n", key.c_str());
        }
        return ret_val;
 }
 
-void DeviceConfig::set_config_value(string key,
-                               string value) {
+bool DeviceConfig::set_config_value(string key,
+                               string value,
+                               bool save_immediately) {
        string  cfg_dir;
        string  cfg_fl;
+       bool    ret_val;
 
-       cfg_dir = get_dir_name(device_id);
+       cfg_dir = get_config_path_name();
        cfg_fl  = DEVICE_CONFIG__FILE_NAME;
-       set_config_value_to_section(uci_handle,
-                       DEVICE_CONFIG__SECTION_TYPE,
-                       DEVICE_CONFIG__SECTION_NAME,
-                       key.c_str(),
-                       value.c_str());
+       if (uci_handle != NULL) {
+               if ((uci_handle->_ctx != NULL) &&
+                   (uci_handle->_pkg != NULL) &&
+                   (uci_handle->short_fname != NULL) &&
+                   (uci_handle->full_fname != NULL)) {
+                       //log_debug("uci_handle != null, short_name: %s, full_name: %s\n",
+                       //      uci_handle->short_fname, uci_handle->full_fname);
+                       //log_debug("key: %s, value: %s\n", key.c_str(), value.c_str());
+                       ret_val = uci_set_config_value(uci_handle->_ctx,
+                                               uci_handle->_pkg,
+                                               uci_handle->short_fname,
+                                               uci_handle->full_fname,
+                                               DEVICE_CONFIG__SECTION_TYPE,
+                                               DEVICE_CONFIG__SECTION_NAME,
+                                               key.c_str(),
+                                               value.c_str(),
+                                               save_immediately);
+               }
+               else {
+                       log_error("Could not set config value for device %s: key: %s, value: %s. Invalid filename in handle.\n",
+                               device_id.c_str(), key.c_str(), value.c_str());
+               }
+       }
+       else {
+               log_error("Could not set config value for device %s: key: %s, value: %s. Invalid handle to config file\n",
+                       device_id.c_str(), key.c_str(), value.c_str());
+       }
+       return ret_val;
 }
 
+// TODO: This function should be moved else where or it should be dynamic...
 EnumSummaryCalculationType DeviceConfig::get_summary_calculation_type() {
-       EnumSummaryCalculationType      ret_val;
-
-       ret_val = MEAN;
        if (device_type.empty() == false) {
                if (device_type.compare("Counter Device") == 0) {
-                       ret_val = DELTA;
+                       return DELTA;
                }
        }
-       return ret_val;;
+       return MEAN;
 }
 
 ConfigHandle *DeviceConfig::load_device_config(string device_id_param) {
        int                     err_flg;
        struct uci_context      *ctx;
        struct uci_package      *pkg;
-       string                  cfg_fl;
+       string                  fname_base;
+       string                  fname_full;
        string                  cfg_dir;
-       int                     b_count;
-       char                    *fname;
        ConfigHandle            *ret_val;
+       FILE                    *fp;
 
        ret_val = NULL;
-       cfg_dir = get_dir_name(device_id_param);
+       cfg_dir = get_config_path_name();
        if (cfg_dir.empty() == false) {
-               if (access(cfg_dir.c_str(), W_OK) != 0) {
-                       FileUtil::mkdirs(cfg_dir.c_str());
-               }
-               cfg_fl  = get_file_name(device_id_param);
-               if (access(cfg_fl.c_str(), R_OK) == 0) {
+               fname_full      = get_config_file_name();
+               if (FileUtil::file_exist(fname_full.c_str(), false) == false)
+                       FileUtil::mkfile(fname_full.c_str(), false);
+               if (access(fname_full.c_str(), R_OK) == 0) {
                        ctx     = uci_alloc_context();
                        if (ctx != NULL) {
-                               log_debug("confdir: %s, file: %s\n", cfg_dir.c_str(), cfg_fl.c_str());
+                               log_debug("configuration file: %s\n", fname_full.c_str());
                                uci_set_confdir(ctx, cfg_dir.c_str());
-                               err_flg = uci_load(ctx, cfg_fl.c_str(), &pkg);
+                               err_flg = uci_load(ctx, fname_full.c_str(), &pkg);
                                if (err_flg == UCI_OK) {
                                        //log_debug("Loaded device configuration: %s.\n", cfg_fl.c_str());
-                                       b_count = strlen(cfg_dir.c_str()) + strlen(cfg_fl.c_str()) + 10;
-                                       fname   = (char *)calloc(1, b_count);
-                                       if (fname != NULL) {
-                                               strncpy(fname, cfg_dir.c_str(), b_count);
-                                               strncat(fname, "/", 1);
-                                               strncat(fname, cfg_fl.c_str(), strlen(cfg_fl.c_str()) + 1);
-
-                                               ret_val = new ConfigHandle(ctx, pkg, cfg_fl.c_str(), fname);
-                                               free(fname);
-                                       }
+                                       fname_base      = get_pathless_config_file_name();
+                                       ret_val = new ConfigHandle(ctx,
+                                                               pkg,
+                                                               fname_base.c_str(),
+                                                               fname_full.c_str());
                                }
                                else {
-                                       log_debug("Failed to load device configuration: %s, err code: %d.\n", cfg_fl.c_str(), UCI_OK);
-                                       set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "");
-                                       uci_free_context(ctx);
+                                       log_debug("Failed to load device configuration: %s, err code: %d.\n", fname_full.c_str(), UCI_OK);
+                                       fp      = fopen(fname_full.c_str(), "w+");
+                                       if (fp != NULL)
+                                               fclose(fp);
+                                       //uci_free_context(ctx);
                                }
                        }
                        else {
                                log_error("Failed to load device configuration, memory allocation error.\n");
-                               set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "");
+                               fp      = fopen(fname_full.c_str(), "w+");
+                               if (fp != NULL)
+                                       fclose(fp);
                        }
                }
                else {
-                       log_error("Failed to load device configuration, file does not exist: %s.\n", cfg_fl.c_str());
+                       log_error("Failed to load device configuration, file does not exist: %s.\n", fname_full.c_str());
                }
        }
        return ret_val;
index 0ede1351afaae9511f875142ea9603a163bbc837..52f2db87397452bc4b60f32819323034dcd8a703 100644 (file)
@@ -9,18 +9,13 @@
 #define DEVICECONFIG_HH_
 
 #include <string>
+#include "DataSummary.hh"
 
 extern "C" {
        #include <uci.h>
        #include <stdbool.h>
 }
 
-enum EnumSummaryPeriod{PERIOD_YEARLY, PERIOD_MONTHLY, PERIOD_DAILY, PERIOD_HOURLY, PERIOD_MINUTELY, PERIOD_SECONDLY};
-enum EnumSummaryCalculationType {SUM, DELTA, MIN, MAX, MEAN};
-
-const std::string SUMMARY_PERIOD_NAMES_ARRAY[]         = {"yearly", "monthly", "daily", "minutely", "secondly"};
-const std::string CALCULATION_TYPE_NAMES_ARRAY[]       = {"sum", "delta", "min", "max", "mean"};
-
 #define DEVICE_CONFIG__FILE_NAME       "device_cfg"
 #define DEVICE_CONFIG__SECTION_TYPE    "device"
 #define DEVICE_CONFIG__SECTION_NAME    "base_data"
@@ -55,9 +50,13 @@ namespace plp {
                        static long get_read_interval_seconds();
                        static void set_read_interval_seconds(long seconds_param);
                        static DeviceConfig *get_device_config(std::string device_id);
-                       std::string get_config_value(std::string key);
-                       void set_config_value(std::string key,
-                                       std::string value);
+                       bool get_config_value(std::string key, std::string& value);
+                       bool set_config_value(std::string key,
+                                       std::string value,
+                                       bool save_immediately);
+                       std::string get_config_path_name();
+                       std::string get_config_file_name();
+                       std::string get_pathless_config_file_name();
                        EnumSummaryCalculationType get_summary_calculation_type();
                private:
                        static std::string      store_base_dir;
@@ -66,8 +65,7 @@ namespace plp {
                        std::string             device_type;
                        ConfigHandle            *uci_handle;
                        ConfigHandle *load_device_config(std::string device_id_param);
-                       std::string get_dir_name(std::string device_id);
-                       std::string get_file_name(std::string device_id_param);
+
        };
 }
 
index 0b97ff94521ffa185533d50a2b8b7b4359252962..1a45e8942b657b4241ad1ba01597b5fcb52fb097 100644 (file)
@@ -38,27 +38,36 @@ FileUtil::FileUtil() {
 FileUtil::~FileUtil() {
 }
 
-char *FileUtil::parse_directory_path(const char *file_path) {
+/*
+ * Parses directory path from the full filename and
+ * returns it's copy.
+ */
+string FileUtil::parse_directory_path(const char *file_name_with_path) {
        char    *p;
        size_t  b_count;
        size_t  f_size;
-       char    *ret_val;
+       char    *ret;
+       string ret_val;
 
-       ret_val = NULL;
-       if (file_path != NULL) {
+       ret     = NULL;
+       if (file_name_with_path != NULL) {
                f_size  = 0;
-               b_count = strlen(file_path);
-               for (p = &((char *)file_path)[b_count]; p != (char *)file_path; p--) {
+               b_count = strlen(file_name_with_path);
+               for (p = &((char *)file_name_with_path)[b_count]; p != (char *)file_name_with_path; p--) {
                        f_size++;
                        if ((*p == '/') ||
                            (*p == '\\')) {
                                b_count = (b_count - f_size) + 1;
-                               ret_val = strndup(file_path, b_count);
-                               log_debug("dir: %s\n", ret_val);
+                               ret     = strndup(file_name_with_path, b_count);
+                               //log_debug("path ret_val: %s\n", ret);
                                break;
                        }
                }
        }
+       if (ret != NULL) {
+               ret_val = ret;
+               free(ret);
+       }
        return ret_val;
 }
 
@@ -69,12 +78,28 @@ bool FileUtil::mkdirs(const char *path) {
 
        ret_val = true;
        if (path != NULL) {
-               // go through each directory one by and and create if not exist
-               for (p = (char *)path; *p; p++) {
-                   if ((p != path) &&
-                       ((*p == '/') ||
-                        (*p == '\\'))) {
-                               *p = '\0';
+               if (access(path, F_OK) != 0) {
+                       // path does not exist, need to create it
+                       // go through each directory one by one and create them if they do not yet exist
+                       for (p = (char *)path; *p; p++) {
+                           if ((p != path) &&
+                               ((*p == '/') ||
+                                (*p == '\\'))) {
+                                       *p = '\0';
+                                       // if dir does not exist, create it
+                                       if (access(path, F_OK) != 0) {
+                                               //log_debug("trying to create directory: %s\n", path);
+                                               err_flg = mkdir(path, S_IRWXU);
+                                               if (err_flg != 0) {
+                                                       log_error("Could not create directory: %s\n", path);
+                                                       ret_val = false;
+                                                       break;
+                                               }
+                                       }
+                                       *p = '/';
+                               }
+                       }
+                       if (ret_val == true) {
                                // if dir does not exist, create it
                                if (access(path, F_OK) != 0) {
                                        //log_debug("trying to create directory: %s\n", path);
@@ -82,22 +107,12 @@ bool FileUtil::mkdirs(const char *path) {
                                        if (err_flg != 0) {
                                                log_error("Could not create directory: %s\n", path);
                                                ret_val = false;
-                                               break;
                                        }
                                }
-                               *p = '/';
                        }
                }
-               if (ret_val == true) {
-                       // if dir does not exist, create it
-                       if (access(path, F_OK) != 0) {
-                               //log_debug("trying to create directory: %s\n", path);
-                               err_flg = mkdir(path, S_IRWXU);
-                               if (err_flg != 0) {
-                                       log_error("Could not create directory: %s\n", path);
-                                       ret_val = false;
-                               }
-                       }
+               else {
+                       ret_val = true;
                }
        }
        else {
@@ -107,8 +122,108 @@ bool FileUtil::mkdirs(const char *path) {
        return ret_val;
 }
 
+bool FileUtil::file_exist(const char *file_name_with_path, bool writable) {
+       bool ret_val;
+       int acl_mode;
+
+       ret_val = false;
+       if (writable == true) {
+               acl_mode        = W_OK;
+       }
+       else {
+               acl_mode        = R_OK;
+       }
+       if (file_name_with_path != NULL) {
+               if (access(file_name_with_path, acl_mode) == 0) {
+                       ret_val = true;
+               }
+       }
+       return ret_val;
+}
+
+bool FileUtil::mkfile(const char *file_name_with_path, bool writable) {
+       bool ret_val;
+       string path_name;
+       const char *acl;
+       int acl_mode;
+       FILE *fp;
+       bool succ_bool;
+
+       ret_val = false;
+       acl     = "a";
+       if (writable == true) {
+               acl_mode        = W_OK;
+       }
+       else {
+               acl_mode        = R_OK;
+       }
+       if (file_name_with_path != NULL) {
+               if (access(file_name_with_path, F_OK) != 0) {
+                       // file does not exist, create it
+                       path_name       = parse_directory_path(file_name_with_path);
+                       succ_bool = true;
+                       if (access(path_name.c_str(), F_OK) != 0) {
+                               // path to file does not exist, create it
+                               succ_bool       = mkdirs(path_name.c_str());
+                       }
+                       if (succ_bool == true) {
+                               // create file with read or write acl rights
+                               fp      = fopen(file_name_with_path, acl);
+                               if (fp != NULL) {
+                                       ret_val = true;
+                                       fclose(fp);
+                               }
+                       }
+               }
+               else {
+                       // file already exist, check access rights and change if needed
+                       ret_val = true;
+                       if (access(file_name_with_path, acl_mode) != 0) {
+                               // file does not have specified acl righs, try to grant them
+                               fp      = fopen(file_name_with_path, acl);
+                               if (fp != NULL) {
+                                       ret_val = true;
+                                       fclose(fp);
+                               }
+                       }
+               }
+       }
+       return ret_val;
+
+/*
+               path_name = parse_directory_path(file_name_with_path)
+               if (cfg_dir.empty() == false) {
+                       if (access(path_name.c_str(), F_OK) != 0) {
+                               // config dir does not exist, create it
+                               FileUtil::mkdirs(cfg_dir.c_str());
+                       }
+                       if (access(cfg_dir.c_str(), R_OK) != 0) {
+                               // config dir does not have read access, add it
+                               fp      = fopen(cfg_dir.c_str(), "r+");
+                               if (fp != NULL)
+                                       fclose(fp);
+                       }
+                       fname_full      = get_config_file_name();
+                       if (access(fname_full.c_str(), F_OK) != 0) {
+                               // config file does not exist, create empty one
+                               fp      = fopen(fname_full.c_str(), "w+");
+                               if (fp != NULL)
+                                       fclose(fp);
+                       }
+                       if (access(fname_full.c_str(), R_OK) != 0) {
+                               // config file does not have read access, add it
+                               fp      = fopen(fname_full.c_str(), "r+");
+                               if (fp != NULL)
+                                       fclose(fp);
+                       }
+                       if (access(fname_full.c_str(), R_OK) == 0) {
+
+                       }
+*/
+}
+
 std::ofstream *FileUtil::open_for_writing(const char *f_path) {
-       char            *d_path;
+       string          path_name;
        size_t          b_count;
        ofstream        *ret_val;
        bool            b_flg;
@@ -122,10 +237,9 @@ std::ofstream *FileUtil::open_for_writing(const char *f_path) {
                        ret_val = new ofstream();
                        ret_val->open(f_path, ios::app);
                        if (ret_val->is_open() == false) {
-                               d_path  = parse_directory_path(f_path);
-                               if (d_path != NULL) {
-                                       b_flg   = mkdirs(d_path);
-                                       free(d_path);
+                               path_name       = parse_directory_path(f_path);
+                               if (path_name.empty() == false) {
+                                       b_flg   = mkdirs(path_name.c_str());
                                }
                                if (b_flg == true) {
                                        ret_val->open(f_path, ios::app);
index e69ada8639fd5b35a8c031438e24d985b6ac3ceb..50b3ddda72f5ee8594d502f579a9203d756e9c72 100644 (file)
@@ -24,8 +24,17 @@ namespace plp {
                        static bool is_datafile(const char *path, dirent *direntry);
                        static std::vector<std::string> get_subdirectories(const std::string& path);
                        static std::vector<std::string> get_data_files(const std::string& path);
-                       static char *parse_directory_path(const char *file_path);
+                       static std::string parse_directory_path(const char *file_name_with_path);
                        static bool mkdirs(const char *path);
+                       /*
+                        * Creates file to given path by first checking whether
+                        * the directories exist and have enough permissions.
+                        */
+                       static bool mkfile(const char *file_name_with_path, bool writable);
+                       /*
+                        * Check whether file exist with specified access rights
+                        */
+                       static bool file_exist(const char *file_name_with_path, bool writable);
                        static std::ofstream *open_for_writing(const char *path);
        };
 }
index b815100f86732d42300ba088fe183f6fd441d777..58153f888e1ecb5137339a7c6b0efa87e63d83c6 100644 (file)
@@ -2,6 +2,7 @@ lib_LTLIBRARIES = libplp.la
 libplp_la_SOURCES = \
        config.c config.h \
        Data.hh Data.cc \
+       DataSummary.hh DataSummary.cc \
        DataReader.hh DataReader.cc \
        Date.hh Date.cc \
        Device.hh Device.cc \
@@ -16,7 +17,8 @@ libplp_la_SOURCES = \
        log.h \
        log_config.c \
        str_util.c str_util.h \
-       retval.h
+       retval.h \
+       private/uci_config.c private/uci_config.h
 libplp_la_LDFLAGS = $(SRC_LIBS) $(all_libraries) -version-info 1:0:0 -no-undefined
 AM_CPPFLAGS = $(SRC_CFLAGS)
 DISTCLEANFILES = Makefile.in
@@ -27,6 +29,7 @@ libplpinclude_HEADERS =   \
         retval.h \
         str_util.h \
         Data.hh \
+        DataSummary.hh \
         DataReader.hh \
         Date.hh \
         Device.hh \
index 3506292c36a01fabb7d3f4ce1cc74f35ed6b74b2..0d62d777f5ba586b89bb1e0c0466d33800c9aabe 100644 (file)
@@ -31,12 +31,17 @@ string StoreCache::get_dir_name(string device_id_param,
        string  ret_val;
        char    buffer[30];
        string  bd_name;
+       string  period_name;
+       string  calc_type;
+
+       period_name     = DataSummary::get_summary_period_name(period_type_param);
+       calc_type       = DataSummary::get_summary_calculation_name(calc_type_param);
 
        bd_name = DeviceConfig::get_base_dir_name();
        bd_name = FileUtil::concat_paths(bd_name, CACHE_DIR_NAME);
        bd_name = FileUtil::concat_paths(bd_name, device_id_param);
-       bd_name = FileUtil::concat_paths(bd_name, SUMMARY_PERIOD_NAMES_ARRAY[period_type_param]);
-       bd_name = FileUtil::concat_paths(bd_name, CALCULATION_TYPE_NAMES_ARRAY[calc_type_param]);
+       bd_name = FileUtil::concat_paths(bd_name, period_name);
+       bd_name = FileUtil::concat_paths(bd_name, calc_type);
        if (period_type_param == PERIOD_YEARLY) {
                ret_val = bd_name;
        }
index a29c6a092dce630cc8947ef017c1844ed268f450..5d71b37cb39ca9e0fc75a4f1d2b28c345f0bf067 100644 (file)
@@ -83,7 +83,7 @@ void StoreDay::save(string device_id,
        /* needs to be casted to long unsigned int value is "unsigned int" in some
            toolchains and that would otherwise cause an warning/error 
         */
-       log_info("[%s] writing %lu data values to save.\n", device_id.c_str(),
+       log_info("[%s] saving %lu data values.\n", device_id.c_str(),
                (long unsigned int)data_list->size());
        // TODO: add mutex to protect string_list while it's read and emptied
        for(iter = data_list->begin(); iter != data_list->end(); iter++) {
index 32f0a93b63ee0d5c1b30819e69031874d44f9d65..9c479a0e255e70c8dac7c6217849cc6c4d49ca79 100644 (file)
 #include <unistd.h>
 #include <uci.h>
 
+#include "private/uci_config.h"
 #include "config.h"
 #include "log.h"
 
-static int uci_create_named_section(struct uci_context *ctx,
-                               const char *conf_file_name,
-                               const char *section_type,
-                               const char *section_name)
-{
-       struct uci_ptr  ptr;
-       int             ret_val;
-       char            *cmd_data;
-       int             len;
-
-       ret_val = -1;
-       if ((ctx != NULL) &&
-           (conf_file_name != NULL) &&
-           (section_type != NULL) &&
-           (section_name != NULL)) {
-               len             = strlen(conf_file_name);
-               len             = len + 1;
-               len             = len + strlen(section_type);
-               len             = len + 1;
-               len             = len + strlen(section_name);
-               len             = len + 1;
-               cmd_data        = malloc(len);
-               if (cmd_data != NULL) {
-                       snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type);
-                       if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) {
-                               ret_val = uci_set(ctx, &ptr);
-                               if (ret_val == UCI_OK) {
-                                       ret_val = uci_save(ctx, ptr.p);
-                               }
-                       }
-                       free(cmd_data);
-               }
-       }
-       return ret_val;
-}
-
-bool set_config_value_to_section(const char *conf_dir_name,
-                       const char *conf_file_name,
+bool set_config_value_and_save(const char *conf_dir_name,
+                       const char *conf_file_basename,
                        const char *section_type,
                        const char *section_name,
                        const char *key,
                        const char *value) {
        struct uci_context      *ctx;
        struct uci_package      *pkg;
-       struct uci_section      *sct;
-       struct uci_section      *tmp_sct;
        int                     err_flg;
-       char                    *fname;
+       char                    *conf_fname_full;
        int                     b_count;
-       struct uci_element      *elem;
-       struct uci_ptr          ptr;
        FILE                    *fp;
        bool                    ret_val;
 
        ret_val = false;
+       pkg     = NULL;
        if ((conf_dir_name != NULL) &&
-           (conf_file_name != NULL) &&
+           (conf_file_basename != NULL) &&
            (section_type != NULL) &&
            (section_name != NULL) &&
            (key != NULL) &&
            (value != NULL)) {
-               b_count = strlen(conf_dir_name) + strlen(conf_file_name) + 10;
-               fname   = (char *)calloc(1, b_count);
-               if (fname != NULL) {
-                       strncpy(fname, conf_dir_name, b_count);
-                       strncat(fname, "/", 1);
-                       strncat(fname, conf_file_name, strlen(conf_file_name) + 1);
+               b_count = strlen(conf_dir_name) + strlen(conf_file_basename) + 10;
+               conf_fname_full = (char *)calloc(1, b_count);
+               if (conf_fname_full != NULL) {
+                       strncpy(conf_fname_full, conf_dir_name, b_count);
+                       strncat(conf_fname_full, "/", 1);
+                       strncat(conf_fname_full, conf_file_basename, strlen(conf_file_basename) + 1);
                        ctx     = uci_alloc_context();
                        if (ctx != NULL) {
-                               sct     = NULL;
-                               uci_set_confdir(ctx, conf_dir_name);
-                               if (access(fname, W_OK) != 0) {
-                                       if (access(fname, F_OK) != 0) {
-                                               fp      = fopen(fname, "w+");
+                               if (access(conf_fname_full, W_OK) != 0) {
+                                       // if file is not writable, try to change it to be writable
+                                       if (access(conf_fname_full, F_OK) != 0) {
+                                               fp      = fopen(conf_fname_full, "w+");
                                                fclose(fp);
                                        }
                                }
-                               if (access(fname, W_OK) == 0) {
-                                       err_flg = uci_load(ctx, fname, &pkg);
-                                       uci_foreach_element(&pkg->sections, elem) {
-                                               tmp_sct = uci_to_section(elem);
-                                               if (strcmp(tmp_sct->type, section_type) == 0) {
-                                                       sct     = tmp_sct;
-                                                       break;
-                                               }
-                                       }
-                                       if (sct == NULL) {
-                                               log_debug("Creating new section %s to configuration file: %s\n", section_name, fname);
-                                               //err_flg       = uci_add_named_section(ctx, pkg, section_type, section_name, &sct);
-                                               //err_flg       = uci_add_section(ctx, pkg, section_name, &sct);
-                                               err_flg = uci_create_named_section(ctx,
-                                                                       conf_file_name,
+                               if (access(conf_fname_full, W_OK) == 0) {
+                                       uci_set_confdir(ctx,
+                                                       conf_dir_name);
+                                       err_flg = uci_load(ctx, conf_fname_full, &pkg);
+                                       if ((err_flg == UCI_OK) &&
+                                           (pkg != NULL)) {
+                                               ret_val = uci_set_config_value(ctx,
+                                                                       pkg,
+                                                                       conf_file_basename,
+                                                                       conf_fname_full,
                                                                        section_type,
-                                                                       section_name);
-                                               if (err_flg == UCI_OK) {
-                                                       uci_foreach_element(&pkg->sections, elem) {
-                                                               tmp_sct = uci_to_section(elem);
-                                                               if (strcmp(tmp_sct->type, section_type) == 0) {
-                                                                       sct     = tmp_sct;
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
+                                                                       section_name,
+                                                                       key,
+                                                                       value,
+                                                                       true);
                                        }
-                                       if (err_flg == UCI_OK) {
-                                               memset(&ptr, 0, sizeof(ptr));
-                                               ptr.package     = pkg->e.name;
-                                               ptr.section     = sct->e.name;
-                                               ptr.option      = key;
-                                               err_flg = uci_lookup_ptr(ctx, &ptr, NULL, false);
-                                               if (err_flg == UCI_OK) {
-                                                       ptr.value       = value;
-                                                       err_flg         = uci_set(ctx, &ptr);
-                                                       if (err_flg == UCI_OK) {
-                                                               err_flg = uci_save(ctx, pkg);
-                                                               if (err_flg == UCI_OK) {
-                                                                       ret_val = true;
-                                                                       log_debug("Set value to section %s in configuration file: %s\n", section_name, fname);
-                                                               }
-                                                               else {
-                                                                       log_error("Failed to set value to configuration file: %s\n. Could not save the file\n", fname);
-                                                               }
+                                       else {
+                                               log_error("Failed to set value to configuration file: %s. Could not load current file content.\n", conf_fname_full);
+                                       }
+                               }
+                               else {
+                                       log_error("Failed to set value to configuration file: %s. File does not exist or is not writable\n", conf_fname_full);
+                               }
+                               //TODO: uci_free_package(pkg) ?, or will uci_free_contect(ctx) also free the package
+                               uci_free_context(ctx);
+                       }
+                       free(conf_fname_full);
+               }
+               else {
+                       log_error("Failed to set value to configuration file: %s/%s, out of memory\n", conf_dir_name, conf_file_basename);
+               }
+       }
+       else {
+               log_error("Failed to set value to configuration file, invalid parameters\n");
+       }
+       return ret_val;
+}
+
+char* get_config_value_and_close(const char *conf_dir_name,
+                       const char *conf_file_basename,
+                       const char *section_name,
+                       const char *key) {
+       struct uci_context      *ctx;
+       struct uci_package      *pkg;
+       int                     err_flg;
+       char                    *conf_fname_full;
+       int                     b_count;
+       FILE                    *fp;
+       char                    *ret_val;
 
-                                                       }
-                                                       else {
-                                                               log_error("Failed to set value to configuration file: %s\n. Could not set new value\n", fname);
-                                                       }
-                                               }
-                                               else {
-                                                       log_error("Failed to set value to configuration file: %s\n. Could not look-up pointer for package %s section %s.\n", fname, pkg->e.name, sct->e.name);
-                                               }
-                                               uci_free_context(ctx);
+       ret_val = NULL;
+       pkg     = NULL;
+       if ((conf_dir_name != NULL) &&
+           (conf_file_basename != NULL) &&
+           (section_name != NULL) &&
+           (key != NULL)) {
+               b_count = strlen(conf_dir_name) + strlen(conf_file_basename) + 10;
+               conf_fname_full = (char *)calloc(1, b_count);
+               if (conf_fname_full != NULL) {
+                       strncpy(conf_fname_full, conf_dir_name, b_count);
+                       strncat(conf_fname_full, "/", 1);
+                       strncat(conf_fname_full, conf_file_basename, strlen(conf_file_basename) + 1);
+                       ctx     = uci_alloc_context();
+                       if (ctx != NULL) {
+                               if (access(conf_fname_full, R_OK) != 0) {
+                                       // if file is not writable, try to change it to be writable
+                                       if (access(conf_fname_full, R_OK) != 0) {
+                                               fp      = fopen(conf_fname_full, "w+");
+                                               fclose(fp);
+                                       }
+                               }
+                               if (access(conf_fname_full, R_OK) == 0) {
+                                       uci_set_confdir(ctx,
+                                                       conf_dir_name);
+                                       err_flg = uci_load(ctx, conf_fname_full, &pkg);
+                                       if ((err_flg == UCI_OK) &&
+                                           (pkg != NULL)) {
+                                               ret_val = uci_get_config_value(ctx,
+                                                                       pkg,
+                                                                       section_name,
+                                                                       key);
+                                               // need to duplicate response val, as uci_free_context() would free the value otherwise
+                                               if (ret_val != NULL)
+                                                       ret_val = strdup(ret_val);
                                        }
                                        else {
-                                               log_error("Failed to set value to configuration file: %s. Could not create section %s.\n", fname, section_name);
+                                               log_error("Failed to get value from configuration file: %s. Could not load current file content.\n", conf_fname_full);
                                        }
                                }
                                else {
-                                       log_error("Failed to set value to configuration file: %s. File does not exist or is not writable\n.", fname);
+                                       log_error("Failed to get value from configuration file: %s. File does not exist or is not readable.\n", conf_fname_full);
                                }
+                               //TODO: uci_free_package(pkg) ?, or will uci_free_contect(ctx) also free the package
+                               uci_free_context(ctx);
                        }
-                       free(fname);
+                       free(conf_fname_full);
                }
                else {
-                       log_error("Failed to set value to configuration file: %s, out of memory\n", fname);
+                       log_error("Failed to get value from configuration file: %s/%s, out of memory.\n", conf_dir_name, conf_file_basename);
                }
        }
        else {
-               log_error("Failed to set value to configuration file, invalid parameters\n");
+               log_error("Failed to get value from configuration file, invalid parameters.\n");
        }
        return ret_val;
 }
index 378ec3e9bae5b9842548029c8318622d03d7da73..69e406d42b98bd77fdff7e11437d51590412c3e9 100644 (file)
 
 #include <stdbool.h>
 
-struct uci_context     *_ctx;
-struct uci_package     *_pkg;
-
-bool set_config_value_to_section(const char *conf_dir_name,
-                       const char *conf_file_name,
+#ifdef __cplusplus
+extern "C"
+#endif
+bool set_config_value_and_save(const char *conf_dir_name,
+                       const char *conf_file_basename,
                        const char *section_type,
                        const char *section_name,
                        const char *key,
                        const char *value);
 
+#ifdef __cplusplus
+extern "C"
+#endif
+char* get_config_value_and_close(const char *conf_dir_name,
+                       const char *conf_file_basename,
+                       const char *section_name,
+                       const char *key);
+
 #endif /* CONFIG_H_ */
diff --git a/src/private/uci_config.c b/src/private/uci_config.c
new file mode 100644 (file)
index 0000000..756f2b7
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * uci_config.c
+ *
+ *  Created on: Aug 2, 2012
+ *      Author: lamikr
+ */
+
+#include "uci_config.h"
+#include "../log.h"
+
+int uci_create_named_section(struct uci_context *ctx,
+                               const char *conf_fname_base,
+                               const char *section_type,
+                               const char *section_name,
+                               bool save_immediately)
+{
+       struct uci_ptr  ptr;
+       int             ret_val;
+       char            *cmd_data;
+       int             len;
+
+       ret_val = -1;
+       if ((ctx != NULL) &&
+           (conf_fname_base != NULL) &&
+           (section_type != NULL) &&
+           (section_name != NULL)) {
+               len             = strlen(conf_fname_base);
+               len             = len + 1;
+               len             = len + strlen(section_type);
+               len             = len + 1;
+               len             = len + strlen(section_name);
+               len             = len + 1;
+               cmd_data        = malloc(len);
+               if (cmd_data != NULL) {
+                       snprintf(cmd_data,
+                               len,
+                               "%s.%s=%s",
+                               conf_fname_base,
+                               section_name,
+                               section_type);
+                       if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) {
+                               ret_val = uci_set(ctx, &ptr);
+                               if (ret_val == UCI_OK) {
+                                       if (save_immediately) {
+                                               ret_val = uci_save(ctx, ptr.p);
+                                       }
+                               }
+                       }
+                       free(cmd_data);
+               }
+       }
+       return ret_val;
+}
+
+bool uci_set_config_value(struct uci_context *ctx,
+                       struct uci_package *pkg,
+                       const char *conf_fname_base,
+                       const char *conf_fname_full,
+                       const char *section_type,
+                       const char *section_name,
+                       const char *key,
+                       const char *value,
+                       const bool save_immediately) {
+       struct uci_section      *sct;
+       struct uci_section      *tmp_sct;
+       int                     err_flg;
+       struct uci_element      *elem;
+       struct uci_ptr          ptr;
+       bool                    ret_val;
+
+       ret_val = false;
+       err_flg = UCI_OK;
+       if ((ctx != NULL) &&
+           (pkg != NULL) &&
+           (section_type != NULL) &&
+           (section_name != NULL) &&
+           (key != NULL) &&
+           (value != NULL)) {
+               sct     = NULL;
+               uci_foreach_element(&pkg->sections, elem) {
+                       tmp_sct = uci_to_section(elem);
+                       if (tmp_sct != NULL) {
+                               if (strcmp(tmp_sct->type, section_type) == 0) {
+                                       sct     = tmp_sct;
+                                       break;
+                               }
+                               else {
+                                       //TODO: uci_free_section(tmp_sct); ?, or will uci_free_contect(ctx) also free the section
+                               }
+                       }
+               }
+               if (sct == NULL) {
+                       //log_debug("Creating new section %s to configuration file: %s\n", section_name, conf_fname_full);
+                       //err_flg       = uci_add_named_section(ctx, pkg, section_type, section_name, &sct);
+                       //err_flg       = uci_add_section(ctx, pkg, section_name, &sct);
+                       err_flg = uci_create_named_section(ctx,
+                                               conf_fname_base,
+                                               section_type,
+                                               section_name,
+                                               false);
+                       if (err_flg == UCI_OK) {
+                               uci_foreach_element(&pkg->sections, elem) {
+                                       tmp_sct = uci_to_section(elem);
+                                       if (strcmp(tmp_sct->type, section_type) == 0) {
+                                               sct     = tmp_sct;
+                                               break;
+                                       }
+                               }
+                       }
+                       //TODO: uci_free_section(sct); ?, or will uci_free_contect(ctx) also free the section
+               }
+               if (err_flg == UCI_OK) {
+                       memset(&ptr, 0, sizeof(ptr));
+                       ptr.package     = pkg->e.name;
+                       ptr.section     = sct->e.name;
+                       ptr.option      = key;
+                       err_flg         = uci_lookup_ptr(ctx, &ptr, NULL, false);
+                       if (err_flg == UCI_OK) {
+                               ptr.value       = value;
+                               err_flg         = uci_set(ctx, &ptr);
+                               log_debug("file: %s, section_key: %s/%s: value: %s.\n",
+                                       conf_fname_full,
+                                       section_name,
+                                       key,
+                                       value);
+                               if (err_flg == UCI_OK) {
+                                       if (save_immediately == true) {
+                                               err_flg = uci_save(ctx, pkg);
+                                               if (err_flg == UCI_OK) {
+                                                       ret_val = true;
+                                               }
+                                               else {
+                                                       log_error("Failed to set value to configuration file: %s. Could not save the file.\n", conf_fname_full);
+                                               }
+                                       }
+                                       else {
+                                               ret_val = true;
+                                       }
+                               }
+                               else {
+                                       log_error("Failed to set value to configuration file: %s. Could not set new value.\n", conf_fname_full);
+                               }
+                       }
+                       else {
+                               log_error("Failed to set value to configuration file: %s. Could not look-up pointer for package %s section %s.\n",
+                                       conf_fname_full,
+                                       pkg->e.name,
+                                       sct->e.name);
+                       }
+               }
+               else {
+                       log_error("Failed to set value to configuration file: %s. Could not create section %s.\n", conf_fname_full, section_name);
+               }
+       }
+       else {
+               log_error("Failed to set value to configuration file, invalid parameters\n");
+       }
+       return ret_val;
+}
+
+char *uci_get_config_value(struct uci_context *ctx,
+                       struct uci_package *pkg,
+                       const char *section_name,
+                       const char *key_name) {
+       struct uci_section      *section;
+       struct uci_option       *option;
+       char                    *ret_val;
+
+       ret_val = NULL;
+       if ((ctx != NULL) &&
+           (pkg != NULL)) {
+               section = uci_lookup_section(ctx,
+                                       pkg,
+                                       section_name);
+               if (section != NULL) {
+                       option  = uci_lookup_option(ctx,
+                                               section,
+                                               key_name);
+                       if (option != NULL) {
+                               switch (option->type) {
+                                       case UCI_TYPE_STRING:
+                                               //log_debug("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string);
+                                               ret_val = option->v.string;
+                                               break;
+                                       default:
+                                               log_error("Failed to read configuration value for key: %s\n", key_name);
+                                               break;
+                               }
+                       }
+                       else {
+                               log_error("Failed to find configuration key: %s\n", key_name);
+                       }
+               }
+               else {
+                       log_error("Failed to find configuration section name: %s\n", section_name);
+               }
+       }
+       return ret_val;
+}
+
+bool uci_save_config_values(struct uci_context *ctx,
+                       struct uci_package *pkg) {
+       bool    ret_val;
+       int     err_flg;
+
+       if ((ctx != NULL) &&
+           (pkg != NULL)) {
+               err_flg = uci_save(ctx, pkg);
+               if (err_flg == UCI_OK) {
+                       ret_val = true;
+               }
+               else {
+                       log_error("Could not save configuration file.\n");
+               }
+       }
+       return ret_val;
+}
diff --git a/src/private/uci_config.h b/src/private/uci_config.h
new file mode 100644 (file)
index 0000000..c06e725
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * uci_config.h
+ *
+ *  Created on: Aug 2, 2012
+ *      Author: lamikr
+ */
+
+#ifndef UCI_CONFIG_H_
+#define UCI_CONFIG_H_
+
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <uci.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int uci_create_named_section(struct uci_context *ctx,
+                               const char *conf_fname_base,    /* filename without directories */
+                               const char *section_type,
+                               const char *section_name,
+                               bool save_immediately);
+
+#ifdef __cplusplus
+extern "C"
+#endif
+bool uci_set_config_value(struct uci_context *ctx,
+                       struct uci_package *pkg,
+                       const char *conf_fname_base,
+                       const char *conf_fname_full,
+                       const char *section_type,
+                       const char *section_name,
+                       const char *key,
+                       const char *value,
+                       const bool save_immediately);
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char *uci_get_config_value(struct uci_context *ctx,
+                       struct uci_package *pkg,
+                       const char *section_name,
+                       const char *key_name);
+
+#ifdef __cplusplus
+extern "C"
+#endif
+bool uci_save_config_values(struct uci_context *ctx,
+                       struct uci_package *pkg);
+
+#endif /* UCI_CONFIG_H_ */
index aca2fd8488a9a055e919f2e38ebc413e55765b68..abf521b6622467521484b7c3afdd46b270bad795 100644 (file)
@@ -8,6 +8,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
+#include <stdbool.h>
+
+#include <log.h>
 
 char *get_as_hex_str(const char *byte_arr, int byte_count) {
        int     ii;
@@ -33,3 +37,26 @@ char *get_as_hex_str(const char *byte_arr, int byte_count) {
        }
        return ret_val;
 }
+
+bool parse_long(const char *str, long *result) {
+       int     new_result;
+       char    *endptr;
+       bool    ret_val;
+
+       ret_val         = false;
+       errno           = 0;
+       new_result      = strtol(str, &endptr, 10);
+       if (errno != 0) {
+               log_error("invalid input %s, could not convert to integer.\n", str);
+       }
+       else {
+               if (endptr == str) {
+                       log_error("invalid input %s, could not convert to integer.\n", str);
+               }
+               else {
+                       *result = new_result;
+                       ret_val = true;
+               }
+       }
+       return ret_val;
+}
index 2a1a599b5ae5c8b25baaef0a08afe9767de12c6b..b73da8a43c0cca8f182f0bd27861eb527ee23527 100644 (file)
@@ -8,6 +8,16 @@
 #ifndef STR_UTIL_H_
 #define STR_UTIL_H_
 
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
 char *get_as_hex_str(const char *byte_arr, int byte_count);
 
+#ifdef __cplusplus
+extern "C"
+#endif
+bool parse_long(const char *str, long *result);
+
 #endif /* STR_UTIL_H_ */
index f8909e60e513e60389e05735f4424b0053b880be..aca423a2ed98415e6ba96f6e27566716bcc39cc5 100644 (file)
@@ -1,15 +1,15 @@
 noinst_PROGRAMS = test_logs \
-               test_config \
-               test_config2
+               test_config1_c \
+               test_config2_cc
 
 test_logs_SOURCES = test_logs.c
 test_logs_LDADD = $(SRC_LIBS) ../src/.libs/libplp.a
 
-test_config_SOURCES = test_config.c
-test_config_LDADD = $(SRC_LIBS) ../src/.libs/libplp.a
+test_config1_c_SOURCES = test_config1.c
+test_config1_c_LDADD = $(SRC_LIBS) ../src/.libs/libplp.a
 
-test_config2_SOURCES = test_config2.c
-test_config2_LDADD = $(SRC_LIBS) ../src/.libs/libplp.a
+test_config2_cc_SOURCES = test_config2.cc
+test_config2_cc_LDADD = $(SRC_LIBS) ../src/.libs/libplp.a
 
 AM_CPPFLAGS = $(SRC_CFLAGS) -I../src
 
diff --git a/src_test/test_config.c b/src_test/test_config.c
deleted file mode 100644 (file)
index ef30eeb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * test_w1.cc
- *
- *  Created on: Oct 20, 2010
- *      Author: lamikr
- */
-#include <unistd.h>
-#include <stdio.h>
-#include "../src/config.h"
-
-void test_config() {
-       char work_dir[FILENAME_MAX];
-
-       getcwd(work_dir, sizeof(work_dir));
-       printf("working directory: %s\n", work_dir);
-
-       set_config_value_to_section(work_dir,
-                       "dev_cfg_txt",
-                       "mysection_type",
-                       "mysection_name",
-                       "myoption_name",
-                       "my_option_value_tmp");
-       set_config_value_to_section(work_dir,
-                       "dev_cfg_txt",
-                       "mysection_type",
-                       "mysection_name",
-                       "myoption_name",
-                       "my_option_value");
-       set_config_value_to_section(work_dir,
-                       "dev_cfg_txt",
-                       "mysection_type",
-                       "mysection_name",
-                       "myoption_name2",
-                       "my_option_value2");
-       set_config_value_to_section(work_dir,
-                       "dev_cfg_txt",
-                       "mysection3_type",
-                       "mysection3_name",
-                       "myoption_name",
-                       "my_option_value3");
-}
-
-int main(int argc, char** argv) {
-       test_config();
-       return 0;
-}
diff --git a/src_test/test_config1.c b/src_test/test_config1.c
new file mode 100644 (file)
index 0000000..8bddb50
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * test_w1.cc
+ *
+ *  Created on: Oct 20, 2010
+ *      Author: lamikr
+ */
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "../src/config.h"
+
+#define CONF_FILENAME  "dev_cfg_txt"
+#define SECTION_TYPE   "mysection_type"
+#define SECTION_TYPE2  "mysection_type2"
+#define SECTION_NAME   "mysection_name"
+#define SECTION_NAME2  "mysection_name2"
+
+#define KEY_NAME       "key_name"
+#define KEY_NAME2      "key_name2"
+#define KEY_NAME3      "key_name3"
+#define KEY_NAME_INVALID_READ  "key_name_invalid"
+
+#define VALUE1         "val1"
+#define VALUE2         "val2"
+#define VALUE3         "val3"
+#define VALUE4         "val4"
+
+int test_config() {
+       char work_dir[FILENAME_MAX];
+       char *val;
+
+       getcwd(work_dir, sizeof(work_dir));
+       printf("working directory: %s\n", work_dir);
+
+       set_config_value_and_save(work_dir,
+                       CONF_FILENAME,
+                       SECTION_TYPE,
+                       SECTION_NAME,
+                       KEY_NAME,
+                       VALUE1);
+       val     = get_config_value_and_close(work_dir,
+                                       CONF_FILENAME,
+                                       SECTION_NAME,
+                                       KEY_NAME);
+       if ((val != NULL) &&
+           (strcmp(val, VALUE1) == 0)) {
+               printf("value 1 read ok: %s\n", val);
+               free(val);
+       }
+       else {
+               printf("failed to read value\n");
+               return 1;
+       }
+
+       val     = get_config_value_and_close(work_dir,
+                                               CONF_FILENAME,
+                                               SECTION_NAME,
+                                               KEY_NAME_INVALID_READ);
+       if ((val != NULL) &&
+           (strcmp(val, VALUE1) == 0)) {
+               printf("pl, should not be possible to read invalid key value.\n");
+               return 0;
+       }
+       else {
+               printf("error, value was supposed to be NULL, but is: %s\n", val);
+       }
+       set_config_value_and_save(work_dir,
+                       CONF_FILENAME,
+                       SECTION_TYPE,
+                       SECTION_NAME,
+                       KEY_NAME,
+                       VALUE2);
+       set_config_value_and_save(work_dir,
+                       CONF_FILENAME,
+                       SECTION_TYPE,
+                       SECTION_NAME,
+                       KEY_NAME2,
+                       VALUE3);
+       set_config_value_and_save(work_dir,
+                       CONF_FILENAME,
+                       SECTION_TYPE2,
+                       SECTION_NAME2,
+                       KEY_NAME3,
+                       VALUE4);
+       return 0;
+}
+
+int main(int argc, char** argv) {
+       test_config();
+       return 0;
+}
diff --git a/src_test/test_config2.c b/src_test/test_config2.c
deleted file mode 100644 (file)
index dfd0987..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * test_w1.cc
- *
- *  Created on: Oct 20, 2010
- *      Author: lamikr
- */
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <uci.h>
-
-#include "log.h"
-#include "config.h"
-
-/*
-static int uci_do_add(int argc, char **argv)
-{
-       struct uci_package *p = NULL;
-       struct uci_section *s = NULL;
-       int ret;
-
-       if (argc != 3)
-               return 255;
-
-       ret = uci_load(ctx, argv[1], &p);
-       if (ret != UCI_OK)
-               goto done;
-
-       ret = uci_add_section(ctx, p, argv[2], &s);
-       if (ret != UCI_OK)
-               goto done;
-
-       ret = uci_save(ctx, p);
-
-done:
-       if (ret != UCI_OK)
-               cli_perror();
-       else if (s)
-               fprintf(stdout, "%s\n", s->e.name);
-       return ret;
-}
-*/
-
-static int uci_create_named_section(struct uci_context *ctx, const char *conf_file_name, const char *section_type, const char *section_name)
-{
-       struct uci_ptr          ptr;
-       int                     ret_val;
-       char                    *cmd_data;
-       int                     len;
-
-       ret_val = -1;
-       if ((ctx != NULL) &&
-           (conf_file_name != NULL) &&
-           (section_type != NULL) &&
-           (section_name != NULL)) {
-               len             = strlen(conf_file_name);
-               len             = len + 1;
-               len             = len + strlen(section_type);
-               len             = len + 1;
-               len             = len + strlen(section_name);
-               len             = len + 1;
-               cmd_data        = malloc(len);
-               if (cmd_data != NULL) {
-                       snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type);
-                       if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) {
-                               ret_val = uci_set(ctx, &ptr);
-                               if (ret_val == UCI_OK) {
-                               }
-                       }
-                       free(cmd_data);
-               }
-       }
-       return ret_val;
-}
-
-bool set_config_value2(const char *conf_dir_name,
-                       const char *conf_file_name,
-                       const char *section_type,
-                       const char *section_name,
-                       const char *key,
-                       const char *value) {
-       struct uci_context      *ctx;
-       struct uci_package      *pkg;
-       struct uci_section      *sct;
-       struct uci_section      *tmp_sct;
-       int                     err_flg;
-       char                    *fname;
-       int                     b_count;
-       struct uci_element      *elem;
-       struct uci_ptr          ptr;
-       FILE                    *fp;
-       bool                    ret_val;
-
-       ret_val = false;
-       if ((conf_dir_name != NULL) &&
-           (conf_file_name != NULL) &&
-           (section_type != NULL) &&
-           (section_name != NULL) &&
-           (key != NULL) &&
-           (value != NULL)) {
-               b_count = strlen(conf_dir_name) + strlen(conf_file_name) + 10;
-               fname   = (char *)calloc(1, b_count);
-               if (fname != NULL) {
-                       strncpy(fname, conf_dir_name, b_count);
-                       strncat(fname, "/", 1);
-                       strncat(fname, conf_file_name, strlen(conf_file_name) + 1);
-                       ctx     = uci_alloc_context();
-                       if (ctx != NULL) {
-                               sct     = NULL;
-                               uci_set_confdir(ctx, conf_dir_name);
-                               if (access(fname, W_OK) != 0) {
-                                       if (access(fname, F_OK) != 0) {
-                                               fp      = fopen(fname, "w+");
-                                               fclose(fp);
-                                       }
-                               }
-                               if (access(fname, W_OK) == 0) {
-                                       err_flg = uci_load(ctx, fname, &pkg);
-                                       uci_foreach_element(&pkg->sections, elem) {
-                                               tmp_sct = uci_to_section(elem);
-                                               if (strcmp(tmp_sct->type, section_type) == 0) {
-                                                       sct     = tmp_sct;
-                                                       break;
-                                               }
-                                       }
-                                       if (sct == NULL) {
-                                               //err_flg       = uci_add_named_section(ctx, pkg, section_type, section_name, &sct);
-                                               //err_flg       = uci_add_section(ctx, pkg, section_name, &sct);
-                                               err_flg = uci_create_named_section(ctx, conf_file_name, section_type, section_name);
-                                               if (err_flg == UCI_OK) {
-                                                       uci_foreach_element(&pkg->sections, elem) {
-                                                               tmp_sct = uci_to_section(elem);
-                                                               if (strcmp(tmp_sct->type, section_type) == 0) {
-                                                                       sct     = tmp_sct;
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                                       if (err_flg == 0) {
-                                               memset(&ptr, 0, sizeof(ptr));
-                                               ptr.package     = pkg->e.name;
-                                               ptr.section     = sct->e.name;
-                                               ptr.option      = key;
-
-                                               if (uci_lookup_ptr(ctx, &ptr, NULL, false) == UCI_OK) {
-                                                       ptr.value       = value;
-                                                       uci_set(ctx, &ptr);
-                                                       uci_save(ctx, pkg);
-                                                       ret_val = true;
-                                                       log_debug("Created configuration section %s to configuration file: %s\n", section_name, fname);
-                                               }
-                                               else {
-                                                       log_error("Could not write to configuration file: %s\n. Could not look-up pointer for package %s section %s.\n", fname, pkg->e.name, sct->e.name);
-                                               }
-                                               uci_free_context(ctx);
-                                       }
-                                       else {
-                                               log_error("Could not write to configuration file: %s\n. Could not create section %s.\n", fname, section_name);
-                                       }
-                               }
-                               else {
-                                       log_error("Could not write to configuration file: %s. File does not exist or is not writable.\n", fname);
-                               }
-                       }
-                       free(fname);
-               }
-               else {
-                       log_error("Could not change config value, out of memory\n");
-               }
-       }
-       else {
-               log_error("Could not change config value, invalid parameters\n");
-       }
-       return ret_val;
-}
-
-void test_config() {
-       char work_dir[FILENAME_MAX];
-
-       getcwd(work_dir, sizeof(work_dir));
-       printf("working directory: %s\n", work_dir);
-
-       set_config_value2(work_dir,
-                       "dev_cfg_txt",
-                       "mysection_type",
-                       "mysection_name",
-                       "myoption_name",
-                       "my_option_value");
-       set_config_value2(work_dir,
-                       "dev_cfg_txt",
-                       "mysection_type",
-                       "mysection_name",
-                       "myoption_name",
-                       "my_option_value2");
-}
-
-int main(int argc, char** argv) {
-       test_config();
-       return 0;
-}
diff --git a/src_test/test_config2.cc b/src_test/test_config2.cc
new file mode 100644 (file)
index 0000000..9b0cf5e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * test_config2.cc
+ *
+ *  Created on: Aug 3, 2012
+ *      Author: lamikr
+ */
+#include <string>
+#include "../src/DeviceConfig.hh"
+#include "../src/FileUtil.hh"
+#include "../src/log.h"
+
+using namespace plp;
+using namespace std;
+
+#define DEVICE_NAME1   "device_1"
+#define KEY_NAME1      "key1"
+#define KEY_NAME2      "key2"
+#define KEY_NAME3      "key3"
+
+#define VALUE_NAME1    "val1"
+#define VALUE_NAME2    "val2"
+#define VALUE_NAME3    "val3"
+
+int test_config() {
+       DeviceConfig *dev_cfg;
+       string val;
+       string fname_full;
+       string fname_path;
+       bool    succ;
+
+       DeviceConfig::set_base_dir_name("/tmp/test");
+       dev_cfg         = new DeviceConfig(DEVICE_NAME1);
+       fname_full      = dev_cfg->get_config_file_name();
+       fname_path      = FileUtil::parse_directory_path(fname_full.c_str());
+       log_info("file-name: %s, path_name: %s\n",
+               fname_full.c_str(), fname_path.c_str());
+       dev_cfg->set_config_value(KEY_NAME1, VALUE_NAME1, false);
+       // check that read works even if values have not been saved yet
+       succ    = dev_cfg->get_config_value(KEY_NAME1, val);
+       if (succ) {
+               log_info("val1: %s\n", val.c_str());
+       }
+       else {
+               log_error("failed to get value for key: %s\n", KEY_NAME1);
+       }
+       dev_cfg->set_config_value(KEY_NAME2, VALUE_NAME2, true);
+       succ    = dev_cfg->get_config_value(KEY_NAME2, val);
+       if (succ) {
+               log_info("val2: %s\n", val.c_str());
+       }
+       else {
+               log_error("failed to get value for key: %s\n", KEY_NAME2);
+       }
+       succ    = dev_cfg->get_config_value(KEY_NAME2, val);
+       if (succ) {
+               log_info("val3: %s\n", val.c_str());
+       }
+       else {
+               log_error("failed to get value for key: %s\n", KEY_NAME2);
+       }
+       dev_cfg->set_config_value(KEY_NAME3, VALUE_NAME3, false);
+       // check whether device_config destructor will do the final save
+       delete(dev_cfg);
+
+       return 0;
+}
+
+int main(int argc, char** argv) {
+       test_config();
+       return 0;
+}