Author: tgoettlicher Date: Tue Jul 1 11:34:36 2008 New Revision: 48704 URL: http://svn.opensuse.org/viewcvs/yast?rev=48704&view=rev Log: added examples how to read and write config files Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/ branches/tmp/jdsn/mod-registration/src/readconfigfiles/README branches/tmp/jdsn/mod-registration/src/readconfigfiles/read_config_file.cpp branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ProductFeatures branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/install.inf branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/proxy branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suseRegister.conf branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suse_register Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/README URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/README?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/README (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/README Tue Jul 1 11:34:36 2008 @@ -0,0 +1,6 @@ +this directory contains an example how +to read and write config/ini files + +RudeConfig Open Source C++ Config File Library +is needed: +http://rudeserver.com/config/api.html Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/read_config_file.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/read_config_file.cpp?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/read_config_file.cpp (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/read_config_file.cpp Tue Jul 1 11:34:36 2008 @@ -0,0 +1,100 @@ +#include "include/config.h" + +#include <iostream> + +using namespace rude; + +int main(void) +{ + Config installinf; + + // it is important to set the delimiter befor loading the file + installinf.setDelimiter(':'); + installinf.load("samplefiles/install.inf"); + + const char *regurl = installinf.getStringValue("regurl"); + const char *regcert = installinf.getStringValue("regcert"); + + std::cout << "file: install.inf" << std::endl; + std::cout << " regurl is [" << regurl << "]" << std::endl; + std::cout << " regcert is [" << regcert << "]" << std::endl; + + + // -------------------------------------------------------------- + + Config productfeatures; + + productfeatures.load("samplefiles/ProductFeatures"); + productfeatures.setSection("globals"); + + bool disable_reg = productfeatures.getBoolValue("disable_register_w3m"); + bool disable_reg_f = productfeatures.getBoolValue("disable_register_forcereg"); + bool enable_reg_h = productfeatures.getBoolValue("enable_register_hwdata"); + bool enable_reg_o = productfeatures.getBoolValue("enable_register_optional"); + bool reg_m = productfeatures.getBoolValue("register_monthly"); + + std::cout << std::endl; + std::cout << "file: ProductFeatures" << std::endl; + std::cout << " disable_register_w3m is [" << disable_reg << "]" << std::endl; + std::cout << " display_register_forcereg is [" << disable_reg_f << "]" << std::endl; + std::cout << " enable_reg_hwdata is [" << enable_reg_h << "]" << std::endl; + std::cout << " enable_reg_optional is [" << enable_reg_o << "]" << std::endl; + std::cout << " register_monthly is [" << reg_m << "]" << std::endl; + + // -------------------------------------------------------------- + + Config proxy; + + proxy.load("samplefiles/proxy"); + + bool proxy_enabled = proxy.getBoolValue("PROXY_ENABLED"); + const char *http = proxy.getStringValue("HTTP_PROXY"); + const char *https = proxy.getStringValue("HTTPS_PROXY"); + + std::cout << std::endl; + std::cout << "file: proxy" << std::endl; + std::cout << " PROXY_ENABLED is [" << proxy_enabled << "]" << std::endl; + std::cout << " HTTP_PROXY is [" << http << "]" << std::endl; + std::cout << " HTTPS_PROXY is [" << https << "]" << std::endl; + + // -------------------------------------------------------------- + + Config susereg; + + susereg.load("samplefiles/suseRegister.conf"); + +// bool proxy_enabled = susereg.getBoolValue("PROXY_ENABLED"); + const char *url = susereg.getStringValue("url"); + const char *params = susereg.getStringValue("listParams"); + const char *reg = susereg.getStringValue("register"); + const char *list = susereg.getStringValue("listProducts"); + const char *guid = susereg.getStringValue("hostGUID"); + + std::cout << std::endl; + std::cout << "file: suseRegister" << std::endl; + std::cout << " url is [" << url << "]" << std::endl; + std::cout << " listParams is [" << params << "]" << std::endl; + std::cout << " register is [" << reg << "]" << std::endl; + std::cout << " hostGUID is [" << guid << "]" << std::endl; + + // -------------------------------------------------------------- + + Config suse_reg; + + suse_reg.load("samplefiles/suse_register"); + + bool submito = suse_reg.getBoolValue("SUBMIT_OPTIONAL"); + bool submith = suse_reg.getBoolValue("SUBMIT_HWDATA"); + + std::cout << std::endl; + std::cout << "file: suse_register" << std::endl; + std::cout << " SUBMIT_OPTIONAL is [" << submito << "]" << std::endl; + std::cout << " SUBMIT_HWDATA is [" << submith << "]" << std::endl; + + // write some data + suse_reg.setBoolValue("SUBMIT_OPTIONAL", false); + suse_reg.save(); + + return 0; +} + Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ProductFeatures URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ProductFeatures?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ProductFeatures (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/ProductFeatures Tue Jul 1 11:34:36 2008 @@ -0,0 +1,60 @@ +[globals] + additional_kernel_parameters = "" + addons_default = "no" + autoconfiguration_default = "yes" + disable_register_w3m = "yes" + display_register_forcereg = "yes" + enable_autoconfiguration = "yes" + enable_autologin = "yes" + enable_clone = "no" + enable_firewall = "yes" + enable_register_hwdata = "yes" + enable_register_optional = "yes" + fam_local_only = "never" + firewall_enable_ssh = "no" + incomplete_translation_treshold = "95" + inform_about_suboptimal_distribution = "yes" + kexec_reboot = "yes" + keyboard = "" + language = "" + manual_online_update = "yes" + online_repositories_default = "yes" + register_monthly = "no" + relnotesurl = "" + root_password_as_first_user = "yes" + root_password_ca_check = "no" + run_you = "yes" + runlevel = "" + show_addons = "yes" + show_online_repositories = "no" + skip_language_dialog = "yes" + timezone = "" + ui_mode = "simple" + vendor_url = "" +[network] + force_static_ip = "no" + network_manager = "laptop" + startmode = "ifplugd" +[partitioning] + boot_evms = "no" + evms_config = "no" + limit_try_home = "7G" + proposal_evms = "no" + proposal_lvm = "no" + root_base_size = "5G" + root_max_size = "20G" + root_space_percent = "40" + try_separate_home = "yes" + use_flexible_partitioning = "no" + vm_desired_size = "15G" + vm_home_max_size = "25G" +[software] + base_selection = "" + delete_old_packages = "yes" + dropped_packages = "ant-jai art-sharp asterisk asterisk-alsa asterisk-capi asterisk-spandsp asterisk-zaptel astools avalon-framework avalon-framework-manual avalon-logkit avalon-logkit-javadoc avmailgate bbtools bitchx blackbox colorgcc compat-curl2 cpp41 cpp42 cups-SUSE-ppds-dat db42 dbus-1-gtk devs dockutils dragonegg ejb-javadoc gal2 gcc41 gcc41-32bit gcc41-ada gcc41-c++ gcc41-fortran gcc41-fortran-32bit gcc41-gij gcc41-gij-32bit gcc41-java gcc41-locale gcc41-objc gcc41-obj-c++ gcc41-objc-32bit gcc42 gcc42-32bit gcc42-c++ gcc42-fortran gcc42-fortran-32bit gcc42-gij gcc42-info gcc42-java gcc42-objc gcc42-objc-32bit gconf-sharp gecko-sharp glade-sharp glib-sharp gnome-keyring-manager gnome-sharp gtk-engines gtkglarea gtkhtml-sharp2 gtk-qt-engine gtk-sharp gtk-sharp-complete gtk-sharp-gapi hermes ial indeview ipgrab ipw3945d ircd jaf-demo jaf-javadoc jaf-manual jai java-1_4_2-cacao java-1_4_2-cacao-devel java-1_4_2-sun java-1_4_2-sun-devel java-1_4_2-sun-plugin javamail-manual jms-javadoc jmx jmx-javadoc jta jta-javadoc kbilliards kfs kino knx kssh libcurl2 libexiv2 libgcc41 libgcc41-32bit libgcj41 libgcj41-32bit libgcj41-devel libgcj42 libgcj42-devel libgfortran42 libgfortran42-32bit libgmime-2_0-2 libgpod libgpod2 libipoddevice libkdcraw1 libkexiv2 libMagick10 libmudflap41 libmudflap41-32bit libpri libqtpod libsoprano3 libsoprano3-32bit libstdc++41 libstdc++41-32bit libstdc++41-devel libstdc++42-devel libWand10 libzypp-zmd-backend limal-bootloader openbox perl-Xmms planmaker qjackconnect radiusclient rsaref rsvg-sharp2 rug samba-pdb sax2-libsax-csharp simutrans sqlite-zmd synce synce-kde tei_3 textmaker tomcat5 tomcat55 tomcat55-common-lib tomcat55-jasper tomcat55-jsp-2_0-api tomcat55-server-lib tomcat55-servlet-2_4-api tpb varmon vte-sharp vte-sharp2 websh wlan-kmp-xen xen-doc-ps xmms xmms-jack xmms-lib yast2-bluetooth yast2-bootfloppy yast2-power-management yast2-powertweak zaptel zaptel-kmp-default zen-updater zmd zope" + external_sources_link = "http://download.opensuse.org/YaST/Repos/openSUSE_110_Servers.xml" + inform_about_suboptimal_distribution = "no" + online_repos_preselected = "no" + only_update_installed = "no" + packages_transmogrify = "" + software_proposal = "selection" Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/install.inf URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/install.inf?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/install.inf (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/install.inf Tue Jul 1 11:34:36 2008 @@ -0,0 +1,54 @@ +Manual: 0 +Locale: en_US +Display: Color +HasPCMCIA: 0 +NoPCMCIA: 0 +Sourcemounted: 0 +SourceType: dir +RepoURL: http://10.10.0.100/dist/full-11.0-i386?device : eth0 +InstsysURL: boot/i386/root +InstMode: http +Device: eth0 +Server: 10.10.0.100 +ServerIP: 10.10.0.100 +Serverdir: dist/full-11.0-i386 +NetConfig: dhcp +Netdevice: eth0 +NetUniqueID: rBUF.Fpg9YYhBwrE +HWAddr: 00:17:a4:cd:8d:ac +NetCardName: Broadcom NetXtreme BCM5788 Gigabit Ethernet +IP: 10.10.102.212 +Hostname: 10.10.102.212 +Broadcast: 10.10.255.255 +Network: 10.10.0.0 +Netmask: 255.255.0.0 +Gateway: 10.10.0.8 +Nameserver: 10.10.0.1 +Nameserver2: 10.10.2.88 +Domain: suse.de nue.novell.com +NISDomain: suse.de +InitrdModules: cdrom processor thermal scsi_mod libata pata_atiixp sata_sil +Options: loop max_loop : 64 +Options: thermal tzp : 50 +UpdateDir: /linux/suse/i386-11.0 +YaST2update: 0 +Textmode: 1 +MemFree: 894980 +VNC: 0 +UseSSH: 0 +InitrdID: 2008-06-09.ca505ff8 +WithiSCSI: 0 +StartShell: 0 +Y2GDB: 0 +kexec_reboot: 1 +Cmdline: splash : silent +Keyboard: 1 +X11i: +XServer: radeon +XVersion: 4 +XBusID: 1:5:0 +XkbRules: xfree86 +XkbModel: pc104 +umount_result: 1 +regurl: http://www.example.org/test +regcert: floppy/path/regcert Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/proxy URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/proxy?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/proxy (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/proxy Tue Jul 1 11:34:36 2008 @@ -0,0 +1,51 @@ +## Path: Network/Proxy +## Description: +## Type: yesno +## Default: no +## Config: kde,profiles +# +# Enable a generation of the proxy settings to the profile. +# This setting allows to turn the proxy on and off while +# preserving the particular proxy setup. +# +PROXY_ENABLED="yes" + +## Type: string +## Default: "" +# +# Some programs (e.g. lynx, arena and wget) support proxies, if set in +# the environment. SuSEconfig can add these environment variables to +# /etc/SuSEconfig/* (sourced by /etc/profile etc.) - +# See http://portal.suse.com/sdb/en/1998/01/lynx_proxy.html for more details. +# Example: HTTP_PROXY="http://proxy.provider.de:3128/" +HTTP_PROXY="http://proxy.suse.de:3128/" + +## Type: string +## Default: "" +# +# Some programs (e.g. lynx, arena and wget) support proxies, if set in +# the environment. SuSEconfig can add these environment variables to +# /etc/SuSEconfig/* (sourced by /etc/profile etc.) - +# this setting is for https connections +HTTPS_PROXY="http://proxy.yast.de:3128/" + +## Type: string +## Default: "" +# +# Example: FTP_PROXY="http://proxy.provider.de:3128/" +# +FTP_PROXY="" + +## Type: string +## Default: "" +# +# Example: GOPHER_PROXY="http://proxy.provider.de:3128/" +# +GOPHER_PROXY="" + +## Type: string(localhost) +## Default: localhost +# +# Example: NO_PROXY="www.me.de, do.main, localhost" +# +NO_PROXY="localhost, 127.0.0.1" Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suseRegister.conf URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suseRegister.conf?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suseRegister.conf (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suseRegister.conf Tue Jul 1 11:34:36 2008 @@ -0,0 +1,15 @@ +url = https://secure-www.novell.com/center/regsvc/ +listParams = command=listparams +register = command=register +listProducts = command=listproducts +#hostGUID = 122354 + +# add update sources provided by the registration server +# +addRegSrvSrc = true + +# add additional update sources (only type zypp is supported) +# addAdSrc can be used multiple times +# +#addAdSrc = http://you.suse.de/updates/test?alias=someName +#addAdSrc = http://you.suse.de/updates/test2 Added: branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suse_register URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suse_register?rev=48704&view=auto ============================================================================== --- branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suse_register (added) +++ branches/tmp/jdsn/mod-registration/src/readconfigfiles/samplefiles/suse_register Tue Jul 1 11:34:36 2008 @@ -0,0 +1,19 @@ +## Path: System/Yast2/SUSEregister +## Description: Online Update Configuration +## Type: boolean +## Default: "" +# +# Send optional data during registration +# +# +SUBMIT_OPTIONAL = false + +## Type: boolean +## Default: "" +# +# Send information about used hardware during registration. +# I order to ship needed drivers in future releases you can +# help us improving the distriburtion by sending data about +# your used hardware. +# +SUBMIT_HWDATA = true -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org