Author: lslezak
Date: Thu Jan 29 08:58:52 2009
New Revision: 55132
URL: http://svn.opensuse.org/viewcvs/yast?rev=55132&view=rev
Log:
- merge - update the base to r55131 from trunk
Added:
branches/tmp/lslezak/core/base/tools/tty_wrapper/ (props changed)
- copied from r55131, trunk/core/base/tools/tty_wrapper/
branches/tmp/lslezak/core/base/tools/tty_wrapper/Makefile.am
- copied unchanged from r55131, trunk/core/base/tools/tty_wrapper/Makefile.am
branches/tmp/lslezak/core/base/tools/tty_wrapper/tty_wrapper.cc
- copied unchanged from r55131, trunk/core/base/tools/tty_wrapper/tty_wrapper.cc
branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.scr.policy
- copied unchanged from r55131, trunk/core/dbus/SCR_service/org.opensuse.yast.scr.policy
branches/tmp/lslezak/core/liby2/src/include/y2/exitcodes.h
- copied unchanged from r55131, trunk/core/liby2/src/include/y2/exitcodes.h
branches/tmp/lslezak/core/liby2util-r/src/include/y2util/y2changes.h
- copied unchanged from r55131, trunk/core/liby2util-r/src/include/y2util/y2changes.h
branches/tmp/lslezak/core/liby2util-r/src/y2changes.cc
- copied unchanged from r55131, trunk/core/liby2util-r/src/y2changes.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinMultiset.cc
- copied unchanged from r55131, trunk/core/libycp/src/YCPBuiltinMultiset.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinSymbol.cc
- copied unchanged from r55131, trunk/core/libycp/src/YCPBuiltinSymbol.cc
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPBuiltinMultiset.h
- copied unchanged from r55131, trunk/core/libycp/src/include/ycp/YCPBuiltinMultiset.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPBuiltinSymbol.h
- copied unchanged from r55131, trunk/core/libycp/src/include/ycp/YCPBuiltinSymbol.h
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Multiset.err
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Multiset.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Multiset.out
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Multiset.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Multiset.ycp
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Multiset.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Symbol.err
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Symbol.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Symbol.out
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Symbol.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Symbol.ycp
- copied unchanged from r55131, trunk/core/libycp/testsuite/tests/builtin/Builtin-Symbol.ycp
Removed:
branches/tmp/lslezak/core/liby2/doc/Y2-access.html.in
branches/tmp/lslezak/core/liby2/doc/Y2-components.html.in
branches/tmp/lslezak/core/liby2/doc/Y2-overview.html
branches/tmp/lslezak/core/liby2/doc/componentbroker.txt
branches/tmp/lslezak/core/liby2/doc/interface.txt
Modified:
branches/tmp/lslezak/core/ (props changed)
branches/tmp/lslezak/core/SUBDIRS
branches/tmp/lslezak/core/VERSION
branches/tmp/lslezak/core/agent-any/doc/ag_anyagent.html (props changed)
branches/tmp/lslezak/core/agent-dummy/doc/ag_dummy.html (props changed)
branches/tmp/lslezak/core/agent-dummy/testsuite/Makefile.am
branches/tmp/lslezak/core/agent-ini/doc/ag_ini.html (props changed)
branches/tmp/lslezak/core/agent-modules/doc/ag_modules.html (props changed)
branches/tmp/lslezak/core/agent-process/doc/ag_process.html (props changed)
branches/tmp/lslezak/core/agent-process/src/Process.cc
branches/tmp/lslezak/core/agent-process/src/Process.h
branches/tmp/lslezak/core/agent-process/testsuite/lib/ag_process_init.exp
branches/tmp/lslezak/core/agent-resolver/doc/ag_resolver.html (props changed)
branches/tmp/lslezak/core/agent-system/src/SystemAgent.cc
branches/tmp/lslezak/core/agents-perl/doc/ag_modinfo.html (props changed)
branches/tmp/lslezak/core/agents-perl/doc/ag_yp_makefile.html (props changed)
branches/tmp/lslezak/core/agents-perl/lib/ycp.pm
branches/tmp/lslezak/core/autodocs/Makefile.am
branches/tmp/lslezak/core/base/src/Makefile.am
branches/tmp/lslezak/core/base/tools/Makefile.am
branches/tmp/lslezak/core/base/tools/ycpc/Makefile.am
branches/tmp/lslezak/core/configure.in.in
branches/tmp/lslezak/core/dbus/SCR_service/ (props changed)
branches/tmp/lslezak/core/dbus/SCR_service/DBusServer.cc
branches/tmp/lslezak/core/dbus/SCR_service/Makefile.am
branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
branches/tmp/lslezak/core/libscr/src/SCR.cc
branches/tmp/lslezak/core/libscr/testsuite/Makefile.am
branches/tmp/lslezak/core/liby2/Makefile.am
branches/tmp/lslezak/core/liby2/doc/Makefile.am
branches/tmp/lslezak/core/liby2/src/genericfrontend.cc
branches/tmp/lslezak/core/liby2/src/include/Y2.h
branches/tmp/lslezak/core/liby2/src/include/y2/Makefile.am
branches/tmp/lslezak/core/liby2/src/include/y2/Y2Component.h
branches/tmp/lslezak/core/liby2/src/include/y2/Y2ComponentBroker.h
branches/tmp/lslezak/core/liby2dbus/ (props changed)
branches/tmp/lslezak/core/liby2dbus/src/DBusConn.cc (props changed)
branches/tmp/lslezak/core/liby2dbus/src/DBusConn.h (props changed)
branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc (props changed)
branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.h (props changed)
branches/tmp/lslezak/core/liby2dbus/src/Makefile.am (props changed)
branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc (contents, props changed)
branches/tmp/lslezak/core/liby2dbus/src/PolKit.h (props changed)
branches/tmp/lslezak/core/liby2util-r/src/ExternalProgram.cc
branches/tmp/lslezak/core/liby2util-r/src/Makefile.am
branches/tmp/lslezak/core/liby2util-r/src/include/y2util/ExternalProgram.h
branches/tmp/lslezak/core/liby2util-r/src/include/y2util/Makefile.am
branches/tmp/lslezak/core/liby2util-r/src/y2log.cc
branches/tmp/lslezak/core/libycp/src/Makefile.am
branches/tmp/lslezak/core/libycp/src/Scanner.cc
branches/tmp/lslezak/core/libycp/src/Type.cc
branches/tmp/lslezak/core/libycp/src/YBlock.cc
branches/tmp/lslezak/core/libycp/src/YBuiltin.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinFloat.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinList.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinMap.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinMisc.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinString.cc
branches/tmp/lslezak/core/libycp/src/YCPBuiltinTerm.cc
branches/tmp/lslezak/core/libycp/src/YCPList.cc
branches/tmp/lslezak/core/libycp/src/YCPMap.cc
branches/tmp/lslezak/core/libycp/src/YCPString.cc
branches/tmp/lslezak/core/libycp/src/YExpression.cc
branches/tmp/lslezak/core/libycp/src/YStatement.cc
branches/tmp/lslezak/core/libycp/src/include/YCP.h
branches/tmp/lslezak/core/libycp/src/include/ycp/Makefile.am
branches/tmp/lslezak/core/libycp/src/include/ycp/Parser.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YBlock.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPCodeCompare.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPList.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPMap.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCPString.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YCode.h
branches/tmp/lslezak/core/libycp/src/include/ycp/YStatement.h
branches/tmp/lslezak/core/libycp/src/include/ycp/pathsearch.h
branches/tmp/lslezak/core/libycp/src/include/ycp/ycpless.h
branches/tmp/lslezak/core/libycp/src/pathsearch.cc
branches/tmp/lslezak/core/libycp/testsuite/Makefile.am
branches/tmp/lslezak/core/libycp/testsuite/runtest.sh
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-List.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-List.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-List2.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-List2.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-List2.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Map.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-Map3.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-String.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-String.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-String.ycp
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin-remove.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin_X.err
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin_X.out
branches/tmp/lslezak/core/libycp/testsuite/tests/builtin/Builtin_X.ycp
branches/tmp/lslezak/core/package/yast2-core.changes
branches/tmp/lslezak/core/scr/src/ScriptingAgent.cc
branches/tmp/lslezak/core/scr/src/StdioSCRAgent.cc
branches/tmp/lslezak/core/scr/src/StdioSCRAgent.h
branches/tmp/lslezak/core/wfm/src/WFM.cc
branches/tmp/lslezak/core/wfm/src/Y2CCWFM.cc
branches/tmp/lslezak/core/wfm/src/Y2WFMComponent.cc
branches/tmp/lslezak/core/wfm/src/Y2WFMComponent.h
branches/tmp/lslezak/core/wfm/testsuite/Makefile.am
branches/tmp/lslezak/core/yast2-core.spec.in
Modified: branches/tmp/lslezak/core/SUBDIRS
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/SUBDIRS?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/SUBDIRS (original)
+++ branches/tmp/lslezak/core/SUBDIRS Thu Jan 29 08:58:52 2009
@@ -1 +1 @@
-liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm base autodocs agent-process dbus
+liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm agent-process base autodocs dbus
Modified: branches/tmp/lslezak/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/VERSION?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/VERSION (original)
+++ branches/tmp/lslezak/core/VERSION Thu Jan 29 08:58:52 2009
@@ -1 +1 @@
-2.17.9
+2.18.2
Modified: branches/tmp/lslezak/core/agent-dummy/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agent-dummy/testsuite/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agent-dummy/testsuite/Makefile.am (original)
+++ branches/tmp/lslezak/core/agent-dummy/testsuite/Makefile.am Thu Jan 29 08:58:52 2009
@@ -12,11 +12,7 @@
noinst_PROGRAMS = y2ag_dummy
y2ag_dummy_SOURCES = y2ag_dummy.cc
-y2ag_dummy_LDADD = \
- ../../liby2/src/liby2.la \
- ../../libycp/src/libycp.la \
- ../../libscr/src/libscr.la \
- ${Y2UTIL_LIBS}
+y2ag_dummy_LDADD = ${AGENT_LIBADD}
y2ag_dummy_LDFLAGS = \
-Xlinker --whole-archive \
../src/libpy2ag_dummy.la \
Modified: branches/tmp/lslezak/core/agent-process/src/Process.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agent-process/src/Process.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agent-process/src/Process.cc (original)
+++ branches/tmp/lslezak/core/agent-process/src/Process.cc Thu Jan 29 08:58:52 2009
@@ -242,3 +242,8 @@
return ExternalProgram::close();
}
+FILE* Process::errorFile()
+{
+ return stderr_output;
+}
+
Modified: branches/tmp/lslezak/core/agent-process/src/Process.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agent-process/src/Process.h?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agent-process/src/Process.h (original)
+++ branches/tmp/lslezak/core/agent-process/src/Process.h Thu Jan 29 08:58:52 2009
@@ -77,9 +77,9 @@
* @param default_locale whether to set LC_ALL=C before starting
* @param use_pty start the process in a terminal
*/
- Process(const std::string &commandline, bool use_pty = false, bool default_locale = false)
+ Process(const std::string &commandline, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
: ExternalProgram(commandline, Stderr_To_FileDesc,
- use_pty, create_stderr_pipes(), default_locale), stderr_output(NULL)
+ use_pty, create_stderr_pipes(), default_locale, "", pty_trans), stderr_output(NULL)
{}
/**
@@ -88,9 +88,9 @@
* overwriting existing ones.
*/
- Process(const char *const *argv, const Environment &environment, bool use_pty = false, bool default_locale = false)
+ Process(const char *const *argv, const Environment &environment, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
: ExternalProgram(argv, environment, Stderr_To_FileDesc,
- use_pty, create_stderr_pipes(), default_locale)
+ use_pty, create_stderr_pipes(), default_locale, "", pty_trans)
{}
@@ -145,6 +145,12 @@
* Read whether there are some buffered lines
*/
bool anyLineInStdout();
+
+ /**
+ * Return the stderror stream
+ */
+ FILE* errorFile();
+
};
#endif // Process_h
Modified: branches/tmp/lslezak/core/agent-process/testsuite/lib/ag_process_init.exp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agent-process/testsuite/lib/ag_process_init.exp?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agent-process/testsuite/lib/ag_process_init.exp (original)
+++ branches/tmp/lslezak/core/agent-process/testsuite/lib/ag_process_init.exp Thu Jan 29 08:58:52 2009
@@ -55,14 +55,22 @@
# check stderr
if {[diff $stderr_name "tmp.err.$base_name"] != 1} {
+ puts "\nThe diff follows...\n"
+ puts [exec sh -c "diff -u $stderr_name tmp.err.$base_name || true"]
+ puts ""
fail "Wrong stderr for $base_name"
+ puts "See the diff above."
return -1
}
# check stdout
if {[diff $stdout_name "tmp.out.$base_name"] != 1} {
+ puts "\nThe diff follows...\n"
+ puts [exec sh -c "diff -u $stdout_name tmp.out.$base_name || true"]
+ puts ""
fail "Wrong stdout for $base_name"
+ puts "See the diff above."
return -1
}
@@ -70,6 +78,9 @@
if {[find . "tests/$base_name.write"] == "./tests/$base_name.write"} {
if {[diff "tests/$base_name.write" "tmp.write.$base_name"] != 1} {
+ puts "\nThe diff follows...\n"
+ puts [exec sh -c "diff -u tests/$base_name.write tmp.write.$base_name || true"]
+ puts ""
fail "Wrong write for $base_name"
return -1
}
Modified: branches/tmp/lslezak/core/agent-system/src/SystemAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agent-system/src/SystemAgent.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agent-system/src/SystemAgent.cc (original)
+++ branches/tmp/lslezak/core/agent-system/src/SystemAgent.cc Thu Jan 29 08:58:52 2009
@@ -275,14 +275,14 @@
{
YCPMap map = value->asMap ();
ret += "$[";
- for (YCPMapIterator i = map->begin (); i != map->end (); i++) {
+ for (YCPMap::const_iterator i = map->begin(); i != map->end(); i++) {
if ( i != map->begin () )
ret += ",";
ret += "\n";
ret += indent_output (level+1);
- ret += dump_value (level+1, i.key ());
+ ret += dump_value (level+1, i->first);
ret += " : ";
- ret += dump_value (level+1, i.value ());
+ ret += dump_value (level+1, i->second);
}
ret += "\n";
ret += indent_output (level);
@@ -946,17 +946,18 @@
}
string exports = "";
- for (YCPMapIterator pos = variables->begin(); pos != variables->end(); ++pos)
+ for (YCPMap::const_iterator pos = variables->begin(); pos != variables->end(); ++pos)
{
- YCPValue key = pos.key();
- YCPValue value = pos.value();
+ const YCPValue& key = pos->first;
+ const YCPValue& value = pos->second;
+
if (!key->isString())
{
return YCPError (string("Invalid value '")
+ key->toString()
+ "' for target variable name, which must be a string");
-
}
+
exports += "export " + key->asString()->value() + "='";
string valstr;
if (value->isString())
Modified: branches/tmp/lslezak/core/agents-perl/lib/ycp.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/agents-perl/lib/ycp.pm?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/agents-perl/lib/ycp.pm (original)
+++ branches/tmp/lslezak/core/agents-perl/lib/ycp.pm Thu Jan 29 08:58:52 2009
@@ -761,8 +761,12 @@
sub BEGIN
{
$Y2DEBUG = $ENV{"Y2DEBUG"};
-
- my @names = ( "/var/log/YaST2/y2log", "$ENV{HOME}/.y2log" );
+ my $home = $ENV{"HOME"};
+ my @names = ( "/var/log/YaST2/y2log" );
+ if (defined ($home))
+ {
+ push(@names, "$home/.y2log")
+ }
if (defined ($ARGV[0]) && $ARGV[0] =~ /^(-l|--log)$/)
{
@names = ( $ARGV[1] );
Modified: branches/tmp/lslezak/core/autodocs/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/autodocs/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/autodocs/Makefile.am (original)
+++ branches/tmp/lslezak/core/autodocs/Makefile.am Thu Jan 29 08:58:52 2009
@@ -13,5 +13,6 @@
index.html: $(wildcard $(top_srcdir)/*/*.cc $(top_srcdir)/*/*/*.cc)
${YDOXYGEN} PROJECT_NAME=@RPMNAME@ \
- INPUT=..
+ INPUT=.. \
+ EXCLUDE=../liby2util-r/testsuite
# TODO: create libzypp.tag and use it (elsewhere)
Modified: branches/tmp/lslezak/core/base/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/base/src/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/base/src/Makefile.am (original)
+++ branches/tmp/lslezak/core/base/src/Makefile.am Thu Jan 29 08:58:52 2009
@@ -10,6 +10,7 @@
../../wfm/src/libpy2wfm.la \
../../scr/src/libpy2scr.la \
../../libycp/src/libycp.la \
+ ../../libycp/src/libycpvalues.la \
../../liby2/src/liby2.la \
../../libscr/src/libscr.la
Modified: branches/tmp/lslezak/core/base/tools/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/base/tools/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/base/tools/Makefile.am (original)
+++ branches/tmp/lslezak/core/base/tools/Makefile.am Thu Jan 29 08:58:52 2009
@@ -2,5 +2,5 @@
# Makefile.am for core/base/tools
#
-SUBDIRS = startshell autorun elf-arch ycpc devtools
+SUBDIRS = startshell autorun elf-arch ycpc devtools tty_wrapper
Modified: branches/tmp/lslezak/core/base/tools/ycpc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/base/tools/ycpc/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/base/tools/ycpc/Makefile.am (original)
+++ branches/tmp/lslezak/core/base/tools/ycpc/Makefile.am Thu Jan 29 08:58:52 2009
@@ -15,6 +15,7 @@
bin_PROGRAMS = ycpc
ycpc_SOURCES = ycpc.cc
ycpc_LDADD = $(top_builddir)/libycp/src/libycp.la \
+ $(top_builddir)/libycp/src/libycpvalues.la \
$(top_builddir)/wfm/src/libpy2wfm.la \
$(top_builddir)/liby2/src/liby2.la \
$(top_builddir)/libscr/src/libscr.la \
Modified: branches/tmp/lslezak/core/configure.in.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/configure.in.in?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/configure.in.in (original)
+++ branches/tmp/lslezak/core/configure.in.in Thu Jan 29 08:58:52 2009
@@ -52,6 +52,7 @@
AGENT_LIBADD='dnl
$(top_builddir)/libscr/src/libscr.la dnl
$(top_builddir)/libycp/src/libycp.la dnl
+ $(top_builddir)/libycp/src/libycpvalues.la dnl
$(top_builddir)/liby2/src/liby2.la dnl
${Y2UTIL_LIBS}'
@@ -130,8 +131,6 @@
## and generate the output
AC_CONFIG_FILES([
- liby2/doc/Y2-access.html
- liby2/doc/Y2-components.html
scr/doc/SCR.html
scr/doc/intro_to_scr.html
])
Modified: branches/tmp/lslezak/core/dbus/SCR_service/DBusServer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/SCR_service/DBusServer.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/SCR_service/DBusServer.cc (original)
+++ branches/tmp/lslezak/core/dbus/SCR_service/DBusServer.cc Thu Jan 29 08:58:52 2009
@@ -25,7 +25,8 @@
// ostringstream
#include <sstream>
-static bool finish = false;
+// use atomic type in signal handler (see bnc#434509)
+static sig_atomic_t finish = 0;
DBusServer::DBusServer()
@@ -426,7 +427,21 @@
{
// create actionId
static const char *polkit_prefix = "org.opensuse.yast.scr";
- std::string action_id(PolKit::createActionId(polkit_prefix, path, method, arg, opt));
+
+ // check the access right to all methods at first (see bnc#449794)
+ std::string action_id(PolKit::createActionId(polkit_prefix, "", method, "", ""));
+
+ if (policykit.isDBusUserAuthorized(action_id, caller, connection.getConnection()))
+ {
+ y2security("User is authorized to do action %s", action_id.c_str());
+ return true;
+ }
+ else
+ {
+ y2debug("User is NOT authorized to do action %s", action_id.c_str());
+ }
+
+ action_id = PolKit::createActionId(polkit_prefix, path, method, arg, opt);
bool ret = false;
Modified: branches/tmp/lslezak/core/dbus/SCR_service/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/SCR_service/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/SCR_service/Makefile.am (original)
+++ branches/tmp/lslezak/core/dbus/SCR_service/Makefile.am Thu Jan 29 08:58:52 2009
@@ -2,7 +2,7 @@
# Makefile.am for dbus/service
#
-EXTRA_DIST=org.opensuse.yast.SCR.service.in org.opensuse.yast.SCR.conf.in
+EXTRA_DIST=org.opensuse.yast.SCR.service.in org.opensuse.yast.SCR.conf.in org.opensuse.yast.scr.policy
AM_CXXFLAGS = -DY2LOG=\"SCR-service\" -DSUSEVERSION=\"${SUSEVERSION}\"
@@ -16,6 +16,14 @@
SCR_dbus_server_LDADD = ${AGENT_LIBADD} $(top_builddir)/liby2dbus/src/liby2dbus.la $(top_builddir)/scr/src/libpy2scr.la
+# PolicyKit defaults
+polkit_policiesdir = `pkg-config --print-errors --variable policydir polkit`
+polkit_policies_DATA = org.opensuse.yast.scr.policy
+
+# validate the policy files in 'make check' target
+check-local:
+ polkit-policy-file-validate $(polkit_policies_DATA)
+
# service activation config
Modified: branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in (original)
+++ branches/tmp/lslezak/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in Thu Jan 29 08:58:52 2009
@@ -1,11 +1,20 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
+<!--
+ Rationale:
+ http://lists.opensuse.org/opensuse-packaging/2009-01/msg00132.html
+ https://bugzilla.novell.com/show_bug.cgi?id=468390
+-->
<policy user="root">
<allow own="org.opensuse.yast.SCR"/>
- <allow send_interface="org.opensuse.yast.SCR.Methods"/>
+ <allow send_destination="org.opensuse.yast.SCR"/>
</policy>
<policy context="default">
- <deny own="org.opensuse.yast.SCR"/>
- <@ACCESS_MODE@ send_interface="org.opensuse.yast.SCR.Methods"/>
+ <!-- allowed iff compiled with PolicyKit -->
+ <@ACCESS_MODE@ send_destination="org.opensuse.yast.SCR"
+ send_interface="org.opensuse.yast.SCR.Methods"/>
+ <!-- introspection is allowed -->
+
</policy>
</busconfig>
Modified: branches/tmp/lslezak/core/libscr/src/SCR.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libscr/src/SCR.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libscr/src/SCR.cc (original)
+++ branches/tmp/lslezak/core/libscr/src/SCR.cc Thu Jan 29 08:58:52 2009
@@ -140,7 +140,9 @@
}
static YCPValue
-SCRWrite2 (const YCPPath &path, const YCPValue& value) {
+SCRWrite2 (const YCPPath &path, const YCPValue& value_n) {
+ YCPValue value = value_n.isNull()? YCPVoid(): value_n; // bnc#406138
+
if (connection != NULL)
{
return CallDBus("Write", path, value);
@@ -156,7 +158,10 @@
}
static YCPValue
-SCRWrite3 (const YCPPath &path, const YCPValue& value, const YCPValue& arg) {
+SCRWrite3 (const YCPPath &path, const YCPValue& value_n, const YCPValue& arg_n) {
+ YCPValue value = value_n.isNull()? YCPVoid(): value_n; // bnc#406138
+ YCPValue arg = arg_n.isNull()? YCPVoid(): arg_n; // bnc#406138
+
if (connection != NULL)
{
return CallDBus("Write", path, value, arg);
@@ -222,7 +227,9 @@
}
static YCPValue
-SCRExecute2 (const YCPPath &path, const YCPValue &arg) {
+SCRExecute2 (const YCPPath &path, const YCPValue &arg_n) {
+ YCPValue arg = arg_n.isNull()? YCPVoid(): arg_n; // bnc#406138
+
if (connection != NULL)
{
return CallDBus("Execute", path, arg);
@@ -235,13 +242,16 @@
}
y2debug( "Running SCR::Execute on SCR agent %p", SCRAgent::instance () );
y2debug( "path: %s", path->toString ().c_str () );
- y2debug( "args: %s", arg.isNull () ? "null" : arg->toString ().c_str () );
+ y2debug( "args: %s", arg->toString ().c_str () );
return SCRAgent::instance ()->Execute (path, arg);
}
static YCPValue
-SCRExecute3 (const YCPPath &path, const YCPValue &arg, const YCPValue &opt) {
+SCRExecute3 (const YCPPath &path, const YCPValue &arg_n, const YCPValue &opt_n) {
+ YCPValue arg = arg_n.isNull()? YCPVoid(): arg_n; // bnc#406138
+ YCPValue opt = opt_n.isNull()? YCPVoid(): opt_n; // bnc#406138
+
if (connection != NULL)
{
return CallDBus("Execute", path, arg, opt);
@@ -254,7 +264,7 @@
}
y2debug( "Running SCR::Execute on SCR agent %p", SCRAgent::instance () );
y2debug( "path: %s", path->toString ().c_str () );
- y2debug( "args: %s,%s", arg.isNull () ? "null" : arg->toString ().c_str (), opt.isNull () ? "null" : opt->toString ().c_str () );
+ y2debug( "args: %s,%s", arg->toString ().c_str (), opt->toString ().c_str () );
return SCRAgent::instance ()->Execute (path, arg, opt);
}
Modified: branches/tmp/lslezak/core/libscr/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libscr/testsuite/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libscr/testsuite/Makefile.am (original)
+++ branches/tmp/lslezak/core/libscr/testsuite/Makefile.am Thu Jan 29 08:58:52 2009
@@ -12,7 +12,7 @@
noinst_PROGRAMS = runscr
runscr_SOURCES = runscr.cc
-runscr_LDADD = ../src/libscr.la ../../liby2/src/liby2.la ../../libycp/src/libycp.la ${Y2UTIL_LIBS} ../../liby2dbus/src/liby2dbus.la
+runscr_LDADD = ${AGENT_LIBADD} ../../liby2dbus/src/liby2dbus.la
PACKAGE = libscr
AUTOMAKE_OPTIONS = dejagnu
Modified: branches/tmp/lslezak/core/liby2/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2/Makefile.am Thu Jan 29 08:58:52 2009
@@ -2,4 +2,4 @@
# Makefile.am for core/liby2
#
-SUBDIRS = src doc
+SUBDIRS = src
Modified: branches/tmp/lslezak/core/liby2/doc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/doc/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/doc/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2/doc/Makefile.am Thu Jan 29 08:58:52 2009
@@ -7,9 +7,6 @@
htmldir = $(docdir)/liby2
html_DATA = \
- Y2-access.html Y2-components.html \
- Y2-overview.html \
- componentbroker.txt \
README.componentsearch
EXTRA_DIST = $(html_DATA)
Modified: branches/tmp/lslezak/core/liby2/src/genericfrontend.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/src/genericfrontend.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/src/genericfrontend.cc (original)
+++ branches/tmp/lslezak/core/liby2/src/genericfrontend.cc Thu Jan 29 08:58:52 2009
@@ -14,17 +14,75 @@
Authors: Mathias Kettner
Arvin Schnell
+ Stanislav Visnovsky
Maintainer: Arvin Schnell
/-*/
-/*
- * main function common to all Y2 components
- */
-
#ifndef _GNU_SOURCE
#define _GNU_SOURCE // needed for vasprintf below
#endif
+/**
+ * \file
+ * Generic \ref main function handler for all YaST2 applications.
+ */
+
+/**
+ * \mainpage Welcome to YaST2 Core System
+ *
+ * \section intro Introduction
+ *
+ * This is the main page of the YaST2 Core documentation. YaST Core is a generic component-based
+ * system to provide the infrastructure for implementing functionality of the YaST
+ * installation and configuration tool.
+ *
+ * \section whatis What is YaST2 Core?
+ *
+ * YaST Core is a collection of libraries to provide an infrastructure for rapid
+ * development of configuration tools. It is a component-based, cross-language
+ * system.
+ *
+ * Some of the general topics are covered by the following pages:
+ *
+ * - Component architecture
+ * - \ref components
+ * - \ref componentbroker
+ * - \ref componentsearch
+ *
+ * - Handling of error codes: \ref exitcodes
+ *
+ * - Libraries
+ * - \ref liby2
+ * - \ref libycp
+ * - \ref libscr
+ *
+ * - Generic components
+ * - \ref SCR
+ * - \ref WFM
+ *
+ * \section community Join the community
+ *
+ * Visit our web site at : http://en.opensuse.org/YaST or #yast on irc.freenode.net
+ *
+ * \section License
+ *
+ * YaST is licensed under GPL v2.
+ *
+ */
+
+/**
+ * \page exitcodes YaST2 Exit Codes
+ *
+ * All applications using liby2 library share a common \ref main function. The function handles the exit codes in the following way.
+ *
+ * The exit codes are described in \ref exitcodes.h header file. A special handling is applied to the value returned from the client.
+ * - If a value is \ref YCPNull or \ref YCPVoid, exitcode \ref YAST_OK will be used.
+ * - If the value is \ref YCPBoolean, \ref YAST_OK will be returned for true, \ref YAST_CLIENTRESULT for false.
+ * - If the value is \ref YCPInteger, the value will be added to \ref YAST_CLIENTRESULT and the resulting
+ * integer will be the process exitcode.
+ * - If the value is \ref YCPSymbol, for names defined by \ref ycp_error_exit_symbols \ref YAST_CLIENTRESULT
+ * will be returned, otherwise \ref YAST_OK.
+ */
#include
#include
#include
@@ -44,12 +102,21 @@
#include
#include
#include
+#include "exitcodes.h"
+
+/// number of symbols that are handled as error codes
+#define MAX_YCP_ERROR_EXIT_SYMBOLS 2
+
+/// symbol names that are handled as error codes when returned by the client
+const char* ycp_error_exit_symbols[MAX_YCP_ERROR_EXIT_SYMBOLS] = {
+ "abort",
+ "cancel"
+};
using std::string;
ExecutionEnvironment ee;
-static const int YCP_ERROR = 16;
-
+/// fallback name of the program
static const char *progname = "genericfrontend";
static void print_usage ();
@@ -262,7 +329,7 @@
if (!argv[arg]) {
print_usage ();
- exit (1);
+ exit (YAST_FEWARGUMENTS);
}
client_name = argv[arg];
@@ -299,13 +366,13 @@
if (option.isNull())
{
print_error ("Client option -s: Couldn't parse valid YCP value from stdin");
- exit (5);
+ exit (YAST_OPTIONERROR);
}
if (!option->isList())
{
print_error ("Client option -s: Parsed YCP value is NOT a YCPList");
- exit (5);
+ exit (YAST_OPTIONERROR);
}
arglist = option->asList(); // the option read _IS_ arglist
@@ -387,13 +454,13 @@
{
fprintf(stderr, "No server module given\n");
print_usage ();
- exit (5);
+ exit (YAST_OPTIONERROR);
}
// now create server
if (!argv[arg]) {
print_usage ();
- exit (1);
+ exit (YAST_FEWARGUMENTS);
}
server_name = argv[arg];
@@ -477,7 +544,7 @@
if (!argv[0])
{
fprintf (stderr, "Missing argv[0]. It is a NULL pointer.");
- exit (5);
+ exit (YAST_OPTIONERROR);
}
progname = basename (argv[0]); // get program name
@@ -501,12 +568,12 @@
if (argc < 2) {
fprintf (stderr, "\nToo few arguments");
print_usage();
- exit (1);
+ exit (YAST_FEWARGUMENTS);
}
if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
print_help ();
- exit (0);
+ exit (YAST_OK);
}
// client _AND_ server must be given
@@ -591,7 +658,7 @@
if (pos == NULL)
{
print_error ("Option %s argument must be in format namespace=component", argv[arg-1]);
- exit (5);
+ exit (YAST_OPTIONERROR);
}
*pos = 0;
Y2ComponentBroker::registerNamespaceException (argv[arg], pos+1);
@@ -689,12 +756,12 @@
fprintf (stderr, " %s\n", i->c_str());
print_usage ();
- exit (5);
+ exit (YAST_OPTIONERROR);
}
if (dynamic_cast(client))
{
print_error ("Error while creating client module %s", client_name);
- exit (5);
+ exit (YAST_OPTIONERROR);
}
@@ -729,10 +796,30 @@
// might be useful in tracking segmentation faults
y2milestone ("Finished YaST2 component '%s'", progname);
- if( !result.isNull () && result->isBoolean() )
- exit( result->asBoolean()->value() ? 0 : YCP_ERROR );
+ if( result.isNull () )
+ exit (YAST_OK);
- exit (EXIT_SUCCESS);
+ y2milestone( "Exiting with client return value '%s'", result->toString ().c_str ());
+
+ if( result->isBoolean () )
+ {
+ exit( result->asBoolean()->value() ? YAST_OK : YAST_CLIENTRESULT );
+ }
+
+ if( result->isInteger () )
+ exit( YAST_CLIENTRESULT + result->asInteger ()->value () );
+
+ // if it is one of error symbols, return it as error
+ if( result->isSymbol () )
+ {
+ string symbol = result->asSymbol()->symbol();
+ for( int i = 0 ; i < MAX_YCP_ERROR_EXIT_SYMBOLS; i++ )
+ if( symbol == ycp_error_exit_symbols[i] )
+ exit( YAST_CLIENTRESULT );
+ }
+
+ // all other values
+ exit (YAST_OK);
}
Modified: branches/tmp/lslezak/core/liby2/src/include/Y2.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/src/include/Y2.h?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/src/include/Y2.h (original)
+++ branches/tmp/lslezak/core/liby2/src/include/Y2.h Thu Jan 29 08:58:52 2009
@@ -26,7 +26,9 @@
#include
#include
-/***
+/**
+ * \page liby2 liby2 Library
+ *
* <h2>The YaST2 component architecture</h2>
*
* <p>The YaST2 system consists of different components. These are
@@ -53,9 +55,9 @@
* time and provide single isolated binaries as well as clusters of components, that need
* not be disjunct.
*
- * <h2>The generic frontend (GF)</h2>
+ * <h2>The generic frontend (y2base)</h2>
*
- * <p>The liby2 provides a main function. A component linked to liby2
+ * <p>The liby2 provides a \ref main function. A component linked to liby2
* therefore need not and cannot have its own main function. This
* generic main function does:
*
@@ -64,36 +66,29 @@
* <li>find the server and the client component regardless, whether they are realized
* as external programs,
* shared library plugins, YCP scripts or objects that are linked to the main binary</li>
- * <li>parameter checking (not yet implemented)
+ * <li>parameter checking
* <li>launches the server and the client component with the correct paramters</li>
* <li>start the communication between client and server</li>
* </ul>
*
* <p>A YaST2 binary does always consist of the generic frontend and zero or more
- * components that are linked in. The binary <tt>y2gf</tt> just contains the frontend
+ * components that are linked in. The binary <tt>y2base</tt> just contains the frontend
* and the builtin components <tt>cat</tt> and <tt>stdio</tt>. <tt>cat</tt> is
* a server component that can be used instead of a user interface. It simply prints
* all commands it gets to stdout and waits for the answer at stdin. <tt>stdio</tt>
* works similary, but is a client.
*
* <p>The general synopsis of a call of a YaST2 binary is:
- * <pre>y2gf [server] client [client-options] [server-options]</pre>
+ * <pre>y2base client server [client-options] [server-options]</pre>
*
* <p><font size="-1">( Please don't ask yet, why the server-options are stated <i>after</i>
* the client options. We will see later. )</font> </p>
*
* <p>An example would be:
- * <pre>y2gf qt mainmenu</pre>
+ * <pre>y2base menu qt</pre>
*
* <p>This call would use the component <tt>qt</tt>, which is the Qt-lib base graphical
- * user interface, as display server and start the module <tt>mainmenu</tt>.
- *
- * <p>If the name of the YaST2 binary is not equal to <tt>y2gf</tt>, then the name
- * without the <tt>y2</tt> is used as the name of the first component:
- * <pre>y2qt mainmenu</pre>
- * <p>This call does the same as the upper one. The generic frontend contained in <tt>y2qt</tt>
- * first looks for a builtin (linked against) component named <tt>qt</tt>. If it finds one
- * <i>in itself</i>, it does not have to launch an external program component.
+ * user interface, as display server and start the module <tt>menu</tt>.
*
* <h3>Server options</h3>
* <p>Every command line argument
Modified: branches/tmp/lslezak/core/liby2/src/include/y2/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/src/include/y2/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/src/include/y2/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2/src/include/y2/Makefile.am Thu Jan 29 08:58:52 2009
@@ -14,7 +14,8 @@
Y2SerialComponent.h Y2StdioComponent.h \
Y2PluginComponent.h Y2CCPlugin.h \
Y2Namespace.h \
- Y2Function.h SymbolEntry.h
+ Y2Function.h SymbolEntry.h \
+ exitcodes.h
#<INSTALL-HEADER-TARGET>
Modified: branches/tmp/lslezak/core/liby2/src/include/y2/Y2Component.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/src/include/y2/Y2Component.h?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/src/include/y2/Y2Component.h (original)
+++ branches/tmp/lslezak/core/liby2/src/include/y2/Y2Component.h Thu Jan 29 08:58:52 2009
@@ -33,8 +33,195 @@
class YCPList;
/**
+ * \page components YaST2 Component Architecture
+ *
+ * \author Mathias Kettner
+ *
+ * \todo This is partially obsolete!
+ *
+ * <h2>Design principles</h2>
+ *
+ * <p>The YaST2 component model is the foundation of the
+ * YaST2 architecture. It is important to understand at least
+ * the basic ideas in order to be able to write new Y2 components.
+ * It's based upon the following design principles:
+ *
+ * <p><table cellspacing=0 BGCOLOR="#f96500" width="100%"><tr><td>
+ * <table width="100%" bgcolor="#ffc080" cellpadding=10><TR><TD>
+ * <ul>
+ *
+ * <p><li><i>YaST2 should be easily extensable. One should be able
+ * to exchange or add functionality independent
+ * of all other parts.</i>This leads to a modular architecture.
+ * The interchangable parts are called 'components'.</li>
+ *
+ * <p><li><i>It should be possible, that a component can be added
+ * or exchanged merely through the fact, that a file has been
+ * added or exchanged.</i> This allows you to put configuration
+ * modules for a software into the same package as that software.
+ * For example you could write a configuration module for
+ * sendmail and put it into the sendmail package. As long as
+ * the sendmail package is installed, its YaST2 configuration
+ * module is available.</li>
+ *
+ * <p><li><i>Despite the need for Y2 to be modular in concept,
+ * during execution time this should not lead to high communication
+ * overhead or large need in memory usage or the number of
+ * concurrently running processes.</i></li>
+ *
+ * <p><li><i>The inter-component communication should be human
+ * readable, at least in debugging situations.</i></li>
+ *
+ * <p><li><i>The inter-component communication should be network
+ * transparent.</i></li>
+ *
+ * <p><li><i>It should be easy to write a component. Component implementing
+ * should not be restricted to a certain programming language.</i>
+ *
+ * </ul>
+ * </td></tr></table>
+ * </td></tr></table>
+ *
+ * <h2>Communication</h2>
+ *
+ * <p>All components speak a common language and act according to
+ * defined protocol. Both the language and the protocol are
+ * called <i>YCP (YaST2 communication protocol)</i>. One protocol
+ * step consists of one of the partners sending exactly one
+ * of \ref ycpvalues to the other and the other receiving that value. In the
+ * next step, the component that just was receiving, is now sending and
+ * vice versa. The only exception is, that one of that partners
+ * may terminate the session and send a last <i>result</i> message
+ * after which - of course - the partner won't send another value.
+ *
+ * <h2>Clients and Servers</h2>
+ *
+ * <p>There are two different kinds of components: server components and
+ * client components, which differ in how the control flows.
+ *
+ * <p>A <i>server</i> component is one that - once it's initialized -
+ * just waits for jobs to do. Another component can send a <i>request</i>
+ * and thus pass the control to the server. That does what is neccessary
+ * in order to do handle the request and returns an
+ * <i>answer</i>. Prominent examples for server components are the user
+ * interfaces. In YaST2 they play a <i>passive</i> role. They just wait
+ * for a command like "Show me this dialog, wait for the next user
+ * input and return me that input". A server component can also use
+ * the service of another server component. For example the <i>SCR
+ * (System configuration repository)</i> makes use of servers called
+ * <i>agents</i>, which realize subtrees of the SCR tree.
+ *
+ * <p>A <i>client</i> component is one that controls the flow. It may
+ * contain something like an "event loop". In order to do its
+ * work, it can use the services of other server components. Client
+ * components are sometimes called <i>modules</i>. Examples for
+ * modules are the single steps of the YaST2 "Installation
+ * Wizard" or the program that calls <tt>rpm</tt> to install
+ * packages. Other examples could be a module that configures the network
+ * setup of a workstation or one, that just sets the IP-number and the
+ * hostname of that workstation.
+ *
+ * <p>Modules can be hiearchically structured
+ * and hand over control to other modules that acomplish sub tasks and
+ * are called <i>submodules</i> in this context. An example is the
+ * structure of the YaST2 installer. The installation itself is
+ * a module. For each of the wizard window steps, it calls a submodule.
+ *
+ * <h2>How components are realized</h2>
+ * <p>There are quite a number of ways how you can implement a component.
+ * A component can be:
+ * <p><table cellspacing=0 BGCOLOR="#f96500" width="100%"><tr><td>
+ * <table width="100%" bgcolor="#ffc080" cellpadding=10><TR><TD>
+ * <ul>
+ *
+ * <li>An executable program (ELF, /bin/sh, or whatsoever)</li>
+ * <li>A C++ class using \ref libycp and \ref liby2</li>
+ * <li>A YCP script executed by the <i>Workflowmanager</i></li>
+ * <li>Youself typing some YCP code at a terminal</li>
+ *
+ * </ul>
+ * </td></tr></table>
+ * </td></tr></table>
+ *
+ * <p>Don't laugh over the last possibility! For debugging this is sometimes
+ * very helpful. You can simulate <i>any</i> component by typing to a terminal.
+ *
+ * <h3>Executable programs</h3>
+ *
+ * <p>A component that exists as <i>executable program</i> is realized by
+ * a process that is created when the component is needed. If a component
+ * needs the services of an external program component, it launches a
+ * seperate process and starts a communication via two unix pipes, one in
+ * each direction.
+ *
+ * <p>The data flowing through these pipes is YCP Ascii
+ * representation. Each communication side needs a parser to analyse the
+ * data and a YCP syntax generater to write data to the pipe. Both can be
+ * found in the \ref libycp, which can only used from C++ programs.
+ *
+ * <p>But the production of YCP code
+ * can in many cases very easily be done be printing to stdout, for
+ * example with <tt>echo</tt> (shell) or <tt>printf</tt> (C).
+ *
+ * <p>The parsing of YCP code is as bit more tricky. But in many cases you
+ * don't need a full featured parser, because you know beforehand what structure
+ * the value have that you get. This especially holds for client components,
+ * because they can decide, how the output from the server should look like.
+ *
+ * <h3>C++ class using libycp and liby2</h3>
+ * <p>If you anyway decide to write your component in C++,
+ * it's by far the most conveniant way to use the functionality
+ * of libycp and liby2, whose only purpose is excactly to support
+ * component implementation.
+ *
+ * <p>What you have to do is to subclass at least two classes:
+ * \ref Y2ComponentCreator and \ref Y2Component and
+ *
+ * <p>Depending on whether you want to implement a server or a client component
+ * you have to override different methods. Many examples can be found within the liby2
+ * itself.
+ *
+ * <p>One big advantage of writing a component in C++ is, that
+ * you can very easily create three external appearances of the component:
+ * <ul>
+ * <li>A selfcontained executable program</li>
+ * <li>A shared library plugin to load during runtime</li>
+ * <li>A static library that can be linked together with other components</li>
+ * </ul>
+ *
+ * <p>The YaST2 installer makes usage of the third variant only. All required components
+ * are linked together to <tt>y2base</tt>, which is statically linked against liby2 and
+ * libycp. The memory usage is reduced as well as the required disk space. Furthermore
+ * no creating and parsing of Ascii streams between the components is required. Protocol
+ * steps are simple function calls. Even for very large data structures, only one pointer
+ * has to be passed.
+ *
+ * <h3>A YCP script executed by the <i>Workflowmanager</i></h3>
+ * <p>If you have installed YaST2, you will find some files ending in <tt>.ycp</tt>
+ * lying around in <tt>/lib/YaST2/clients</tt>. These are YCP scripts implementing
+ * client components (modules). YCP is not only a protocol, it is also a full features
+ * programming language, which is in this case used to implement components. This is
+ * very conveniant as the language can directly operate on the protocol values and
+ * has some other nice features.
+ *
+ * <p>The client scripts are executed by the <i>Workflowmanager</i>, which is an
+ * extension to the core YCP language. It implements a couple of builtin functions
+ * that allow communication the the system and with other
+ * components. Here is a
+ * <a href="../y2wfm/YCP-builtins-wfm.html">of builtins.</a>.
+ *
+ * <h3>Youself typing YCP code at a terminal</h3>
+ * <p>You can be a component yourself :-). Just tell another component to communicate
+ * via stdio and speak with it. For example you can launch the component <tt>ycp</tt> by
+ * typing <tt>y2ycp stdio</tt>. Now you can enter YCP expressions and get the evaluation
+ * as answer.
+ */
+
+/**
* @short Communication handle to a YaST2 component.
- * @see Y2ComponentBroker.
+ * @see componentbroker
+ * @see Y2ComponentBroker
+ *
* YaST2 is a network oriented client/server architecture.
* Currently there exist five differnt types of components:
* userinterfaces, modules, the workflowmanagers, the
Modified: branches/tmp/lslezak/core/liby2/src/include/y2/Y2ComponentBroker.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2/src/include/y2/Y2ComponentBroker.h?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2/src/include/y2/Y2ComponentBroker.h (original)
+++ branches/tmp/lslezak/core/liby2/src/include/y2/Y2ComponentBroker.h Thu Jan 29 08:58:52 2009
@@ -34,6 +34,41 @@
class Y2Component;
/**
+ * \page componentbroker YaST2 Component Broker
+ * \author Matthias Kettner
+ * \todo clean up and update
+ *
+ * <h2>How the component broker works</h2>
+ *
+ * liby2 is the library which does all the stuff
+ *
+ * in \ref Y2ProgramComponent.cc the server/client is started
+ * (\ref launchExternalProgram) by connecting pipes for stdin/stdout
+ * and starting the program via fork/execve.
+ *
+ * The program is searched via \ref pathsearch.cc and must reside
+ * in a sub-directory "clients" or "servers".
+ * The $HOME directory is a special case, as a sub-dir $HOME/.yast2
+ * must exists.
+ *
+ * Every program starts via \ref main() \ref genericfrontend.cc
+ *
+ * The \ref main() function parses argv and starts
+ * the client (\ref Y2ComponentBroker::createClient) and the
+ * server (\ref Y2ComponentBroker::createServer) for the component
+ *
+ * Expressions are 'commands' to the server and sent via
+ * "...Component::evaluate (const YCPValue& command)"
+ *
+ * evaluate() starts the 'real' component if it is not already
+ * running.
+ *
+ * \ref doActualWork() is used for client components
+ *
+ * \ref result() is used to finish server components
+ */
+
+/**
* @short Looks for and creates YaST2 components
* This class has no instances and only static methods.
* There are two reasons for this:
@@ -50,6 +85,8 @@
* exist. During global constructor call time (before main), the
* constructors of the @ref ComponentCreator classes <i>register</i>
* themselves to the component broker.
+ *
+ * For more details, see \page componentbroker
*/
class Y2ComponentBroker
{
Modified: branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc Thu Jan 29 08:58:52 2009
@@ -25,11 +25,22 @@
y2debug("Checking action %s from %s", action_id.c_str(), dbus_caller.c_str());
PolKitCaller *pk_caller = polkit_caller_new_from_dbus_name(con, dbus_caller.c_str(), &dbus_error);
+
if (dbus_error_is_set (&dbus_error))
{
- y2error ("dbus error: %s: %s", dbus_error.name, dbus_error.message);
+ // PolKit sometimes sets the error even if the PolKitCaller object has been successfully returned
+ // see bnc#439150
+ if (pk_caller == NULL)
+ {
+ y2error ("dbus error: %s: %s", dbus_error.name, dbus_error.message);
+ }
+
dbus_error_free (&dbus_error);
- return false;
+
+ if (pk_caller == NULL)
+ {
+ return false;
+ }
}
if (pk_caller == NULL)
Modified: branches/tmp/lslezak/core/liby2util-r/src/ExternalProgram.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2util-r/src/ExternalProgram.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2util-r/src/ExternalProgram.cc (original)
+++ branches/tmp/lslezak/core/liby2util-r/src/ExternalProgram.cc Thu Jan 29 08:58:52 2009
@@ -25,6 +25,7 @@
#include
#include // openpty
#include // setenv
+#include // tcsetattr()
#include <cstring> // strsignal
@@ -36,8 +37,8 @@
ExternalProgram::ExternalProgram (string commandline,
Stderr_Disposition stderr_disp, bool use_pty,
int stderr_fd, bool default_locale,
- const Pathname& root)
- : use_pty (use_pty)
+ const Pathname& root, bool pty_trans)
+ : use_pty (use_pty), disable_pty_trans(!pty_trans)
{
const char *argv[4];
argv[0] = "/bin/sh";
@@ -58,8 +59,8 @@
ExternalProgram::ExternalProgram (const char *const *argv,
Stderr_Disposition stderr_disp, bool use_pty,
int stderr_fd, bool default_locale,
- const Pathname& root)
- : use_pty (use_pty)
+ const Pathname& root, bool pty_trans)
+ : use_pty (use_pty), disable_pty_trans(!pty_trans)
{
const char* rootdir = NULL;
if(!root.empty() && root != "/")
@@ -74,8 +75,8 @@
ExternalProgram::ExternalProgram (const char *const *argv, const Environment & environment,
Stderr_Disposition stderr_disp, bool use_pty,
int stderr_fd, bool default_locale,
- const Pathname& root)
- : use_pty (use_pty)
+ const Pathname& root, bool pty_trans)
+ : use_pty (use_pty), disable_pty_trans(!pty_trans)
{
const char* rootdir = NULL;
if(!root.empty() && root != "/")
@@ -87,8 +88,8 @@
ExternalProgram::ExternalProgram (const char *binpath, const char *const *argv_1,
- bool use_pty)
- : use_pty (use_pty)
+ bool use_pty, bool pty_trans)
+ : use_pty (use_pty), disable_pty_trans(!pty_trans)
{
int i = 0;
while (argv_1[i++])
@@ -102,8 +103,8 @@
ExternalProgram::ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
- bool use_pty)
- : use_pty (use_pty)
+ bool use_pty, bool pty_trans)
+ : use_pty (use_pty), disable_pty_trans(!pty_trans)
{
int i = 0;
while (argv_1[i++])
@@ -119,6 +120,39 @@
{
}
+// disable LF to CRLF translation on the terminal file descriptor
+// see 'man termios' or stty.c in core-utils for more info
+bool ExternalProgram::disableCRLFTranslation(int fd)
+{
+ if (!isatty(fd))
+ {
+ ERR << "The file descriptor is not a terminal!\n";
+ return false;
+ }
+
+ // properties of the terminal
+ struct termios mode;
+
+ // get the current attributes
+ if (tcgetattr(fd, &mode))
+ {
+ ERR << "tcgetattr() failed: " << strerror(errno) << endl;
+ return false;
+ }
+
+ // disable the LF to CRLF translation in the output flag
+ mode.c_oflag = mode.c_oflag & ~ONLCR;
+
+ // TCSADRAIN should be used when changing output flags (see 'man termios')
+ if (tcsetattr(fd, TCSADRAIN, &mode))
+ {
+ ERR << "tcsetattr() failed: " << strerror(errno) << endl;
+ return false;
+ }
+
+ return true;
+}
+
void
ExternalProgram::start_program (const char *const *argv, const Environment & environment,
@@ -139,6 +173,11 @@
ERR << "openpty failed" << endl;
return;
}
+
+ if (disable_pty_trans)
+ {
+ disableCRLFTranslation(slave_tty);
+ }
}
else
{
Modified: branches/tmp/lslezak/core/liby2util-r/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2util-r/src/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2util-r/src/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2util-r/src/Makefile.am Thu Jan 29 08:58:52 2009
@@ -22,7 +22,8 @@
Y2SLog.cc \
miniini.cc \
stringutil.cc \
- y2log.cc
+ y2log.cc \
+ y2changes.cc
liby2util_la_LDFLAGS = -version-info 4:0:0
Modified: branches/tmp/lslezak/core/liby2util-r/src/include/y2util/ExternalProgram.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2util-r/src/include/y2util/ExternalProgram.h?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2util-r/src/include/y2util/ExternalProgram.h (original)
+++ branches/tmp/lslezak/core/liby2util-r/src/include/y2util/ExternalProgram.h Thu Jan 29 08:58:52 2009
@@ -64,7 +64,7 @@
ExternalProgram (std::string commandline,
Stderr_Disposition stderr_disp = Normal_Stderr,
bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
- const Pathname& root = "");
+ const Pathname& root = "", bool pty_trans = true);
/**
* Start an external program by giving the arguments as an arry of char *pointers.
@@ -74,19 +74,19 @@
ExternalProgram (const char *const *argv,
Stderr_Disposition stderr_disp = Normal_Stderr,
bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
- const Pathname& root = "");
+ const Pathname& root = "", bool pty_trans = true);
ExternalProgram (const char *const *argv, const Environment & environment,
Stderr_Disposition stderr_disp = Normal_Stderr,
bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
- const Pathname& root = "");
+ const Pathname& root = "", bool pty_trans = true);
ExternalProgram (const char *binpath, const char *const *argv_1,
- bool use_pty = false);
+ bool use_pty = false, bool pty_trans = true);
ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
- bool use_pty = false);
+ bool use_pty = false, bool pty_trans = true);
~ExternalProgram();
@@ -124,6 +124,12 @@
*/
bool use_pty;
+ /**
+ * Set to true if LF to CRLF output tranformation on the pty
+ * will be disabled
+ */
+ bool disable_pty_trans;
+
pid_t pid;
int _exitStatus;
@@ -132,6 +138,8 @@
int stderr_fd = -1, bool default_locale = false,
const char* root = NULL);
+ // disable LF to CRLF translation on the terminal file descriptor
+ bool disableCRLFTranslation(int fd);
};
#endif // ExternalProgram_h
Modified: branches/tmp/lslezak/core/liby2util-r/src/include/y2util/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2util-r/src/include/y2util/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2util-r/src/include/y2util/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2util-r/src/include/y2util/Makefile.am Thu Jan 29 08:58:52 2009
@@ -19,7 +19,8 @@
Y2SLog.h \
miniini.h \
stringutil.h \
- y2log.h
+ y2log.h \
+ y2changes.h
#<INSTALL-HEADER-TARGET>
Modified: branches/tmp/lslezak/core/liby2util-r/src/y2log.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2util-r/src/y2log.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2util-r/src/y2log.cc (original)
+++ branches/tmp/lslezak/core/liby2util-r/src/y2log.cc Thu Jan 29 08:58:52 2009
@@ -72,14 +72,16 @@
inisection logconf;
static bool did_set_logname = false;
-static bool did_read_logconf = false;
+// use atomic type in signal handler (see bnc#434509)
+static sig_atomic_t did_read_logconf = 0;
static const char *logname;
static off_t maxlogsize;
static int maxlognum;
-static bool log_debug = false;
+// use atomic type in signal handler (see bnc#434509)
+static sig_atomic_t log_debug = false;
static bool log_to_file = true;
static bool log_to_syslog = false;
Modified: branches/tmp/lslezak/core/libycp/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/Makefile.am?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/Makefile.am (original)
+++ branches/tmp/lslezak/core/libycp/src/Makefile.am Thu Jan 29 08:58:52 2009
@@ -45,7 +45,8 @@
YCPBuiltinList.cc YCPBuiltinBoolean.cc \
YCPBuiltinString.cc YCPBuiltinTerm.cc \
YCPBuiltinVoid.cc YCPBuiltinMap.cc \
- YCPBuiltinMisc.cc \
+ YCPBuiltinMisc.cc YCPBuiltinSymbol.cc \
+ YCPBuiltinMultiset.cc \
YSymbolEntry.cc \
TypeStatics.cc \
y2string.cc \
Modified: branches/tmp/lslezak/core/libycp/src/Scanner.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/Scanner.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/Scanner.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/Scanner.cc Thu Jan 29 08:58:52 2009
@@ -23,6 +23,7 @@
#include <string>
#include
#include
+#include
#include "ycp/Scanner.h"
#include "ycp/y2log.h"
@@ -216,7 +217,12 @@
else if (m_inputFd >= 0)
{
- ssize_t read_bytes = read (m_inputFd, buf, m_buffered ? maxnum : 1);
+ ssize_t read_bytes;
+ do {
+ read_bytes = read (m_inputFd, buf, m_buffered ? maxnum : 1);
+ } while (read_bytes == -1 &&
+ (errno == EINTR || errno == ERESTART)); // bnc#434253
+
if (read_bytes >= 0)
return read_bytes;
else
Modified: branches/tmp/lslezak/core/libycp/src/Type.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/Type.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/Type.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/Type.cc Thu Jan 29 08:58:52 2009
@@ -21,7 +21,7 @@
#include "ycp/Type.h"
#include "ycp/Bytecode.h"
#include "ycp/Xmlcode.h"
-#include "ycp/YCPMap.h" // for YCPMapIterator
+#include "ycp/YCPMap.h"
#include "ycp/YCPCode.h" // for YT_Code in matchvalue()
#ifndef DO_DEBUG
@@ -455,10 +455,10 @@
// check every map element
YCPMap mvalue = value->asMap();
- for (YCPMapIterator i = mvalue->begin(); i != mvalue->end(); i++)
+ for (YCPMap::const_iterator i = mvalue->begin(); i != mvalue->end(); ++i)
{
- YCPValue kvalue = i.key(); // get map key value
- YCPValue evalue = i.value(); // get map element value
+ YCPValue kvalue = i->first; // get map key value
+ YCPValue evalue = i->second; // get map element value
y2debug ("kvalue '%s', evalue '%s'", kvalue->toString().c_str(), evalue->toString().c_str());
if (key_type->matchvalue (kvalue) < 0)
{
Modified: branches/tmp/lslezak/core/libycp/src/YBlock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YBlock.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YBlock.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YBlock.cc Thu Jan 29 08:58:52 2009
@@ -475,7 +475,7 @@
string
-YBlock::toStringSwitch (map cases, int defaultcase) const
+YBlock::toStringSwitch (map cases, int defaultcase) const
{
// first, create reverse map of cases
int statementcount = statementCount ();
@@ -484,7 +484,7 @@
for (int i = 0; i < statementcount; i++)
values[i] = YCPNull ();
- for (map::iterator it = cases.begin ();
+ for (map::iterator it = cases.begin ();
it != cases.end (); it++ )
{
values[ it->second ] = it->first;
@@ -519,7 +519,7 @@
std::ostream &
-YBlock::toXmlSwitch( map cases, int defaultcase, std::ostream & str, int indent ) const
+YBlock::toXmlSwitch( map cases, int defaultcase, std::ostream & str, int indent ) const
{
// first, create reverse map of cases
int statementcount = statementCount ();
@@ -528,7 +528,7 @@
for (int i = 0; i < statementcount; i++)
values[i] = YCPNull ();
- for (map::iterator it = cases.begin ();
+ for (map::iterator it = cases.begin ();
it != cases.end (); it++ )
{
values[ it->second ] = it->first;
Modified: branches/tmp/lslezak/core/libycp/src/YBuiltin.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YBuiltin.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YBuiltin.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YBuiltin.cc Thu Jan 29 08:58:52 2009
@@ -50,6 +50,12 @@
#include "ycp/YCPBuiltinList.h"
static YCPBuiltinList builtin_list; // trigger constructor
+#include "ycp/YCPBuiltinMultiset.h"
+static YCPBuiltinMultiset builtin_multiset; // trigger constructor
+
+#include "ycp/YCPBuiltinSymbol.h"
+static YCPBuiltinSymbol builtin_symbol; // trigger constructor
+
#include "ycp/YCPBuiltinMap.h"
static YCPBuiltinMap builtin_map; // trigger constructor
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinFloat.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinFloat.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinFloat.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinFloat.cc Thu Jan 29 08:58:52 2009
@@ -313,8 +313,6 @@
{ "-", "float (float)", (void *)f_neg },
{ "*", "float (float, float)", (void *)f_mult },
{ "/", "float (float, float)", (void *)f_div },
- { "trunc", "float (float)", (void *)f_trunc, DECL_DEPRECATED },
- { "pow", "float (float, float)", (void *)f_pow, DECL_DEPRECATED },
{ "tofloat", "float (const any)", (void *)f_tofloat },
{ "tostring","string (float, integer)", (void *)f_tostring },
{ 0 }
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinList.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinList.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinList.cc Thu Jan 29 08:58:52 2009
@@ -72,10 +72,9 @@
SymbolEntryPtr s = symbol->asEntry()->entry();
- for (int i = 0; i < list->size (); i++)
+ for (YCPList::const_iterator it = list->begin(); it != list->end(); ++it)
{
- YCPValue element = list->value (i);
- s->setValue (element);
+ s->setValue(*it);
YCPValue v = expr->evaluate ();
@@ -93,7 +92,7 @@
if (v->asBoolean ()->value ())
{
- ret = element;
+ ret = *it;
break;
}
}
@@ -144,20 +143,7 @@
* @usage contains ([1, 2, 5], 2) -> true
*/
- if (list.isNull ())
- {
- return YCPNull ();
- }
-
- for (int i = 0; i < list->size (); i++)
- {
- if (list->value (i)->equal (value))
- {
- return YCPBoolean (true);
- }
- }
-
- return YCPBoolean (false);
+ return YCPBoolean(list->contains(value));
}
@@ -179,35 +165,7 @@
* @usage setcontains ([1, 2, 5], 2) -> true
*/
- if (list.isNull ())
- {
- return YCPNull ();
- }
-
- int hi = list->size () - 1;
- int lo = 0;
-
- while (lo <= hi)
- {
- int mid = (hi + lo) / 2;
- YCPValue midvalue = list->value (mid);
- YCPOrder comp = value->compare (midvalue);
-
- switch (comp)
- {
- case YO_EQUAL:
- return YCPBoolean (true);
- break;
- case YO_LESS:
- hi = mid - 1;
- break;
- case YO_GREATER:
- lo = mid + 1;
- break;
- }
- }
-
- return YCPBoolean (false);
+ return YCPBoolean(binary_search(list->begin(), list->end(), value, ycp_less()));
}
@@ -254,18 +212,8 @@
// Already contained? I know, this has an _awful_ complexity.
// We need to introduce an order on YCPValueRep to solve the problem.
- bool contained = false;
- for (int a = 0; a < newlist->size (); a++)
- {
- if (newlist->value (a)->equal (to_insert))
- {
- contained = true;
- break;
- }
- }
-
- if (!contained)
+ if (!newlist->contains(to_insert))
newlist->add (to_insert);
}
}
@@ -440,10 +388,9 @@
SymbolEntryPtr s = symbol->asEntry()->entry();
- for (int i = 0; i < list->size (); i++)
+ for (YCPList::const_iterator it = list->begin(); it != list->end(); ++it)
{
- YCPValue element = list->value (i);
- s->setValue (element);
+ s->setValue(*it);
YCPValue v = expr->evaluate ();
@@ -464,7 +411,7 @@
}
if (v->asBoolean ()->value ())
{
- ret->add (element);
+ ret->add(*it);
}
}
@@ -501,9 +448,9 @@
YCPList ret;
SymbolEntryPtr s = symbol->asEntry()->entry();
- for (int i = 0; i < list->size (); i++)
+ for (YCPList::const_iterator it = list->begin(); it != list->end(); ++it)
{
- s->setValue (list->value (i));
+ s->setValue(*it);
YCPValue v = expr->evaluate ();
@@ -558,9 +505,9 @@
YCPList curr_list;
YCPMap curr_map;
- for (int i = 0; i < list->size (); i++)
+ for (YCPList::const_iterator it = list->begin(); it != list->end(); ++it)
{
- key->setValue (list->value (i));
+ key->setValue(*it);
YCPValue curr_value = expr->evaluate ();
@@ -584,8 +531,8 @@
curr_map = curr_value->asMap();
if ( curr_map->size() == 1 )
{
- YCPMapIterator it = curr_map->begin();
- ret->add (it.key(), it.value());
+ YCPMap::const_iterator it = curr_map->begin();
+ ret->add(it->first, it->second);
}
else
{
@@ -658,20 +605,10 @@
* @usage toset ([1, 5, 3, 2, 3, true, false, true]) -> [false, true, 1, 2, 3, 5]
*/
- if (list.isNull ())
- {
- return YCPNull ();
- }
-
- set newset;
-
- for (int i = 0; i < list->size (); i++)
- {
- newset.insert (list->value (i));
- }
+ set newset(list->begin(), list->end());
YCPList setlist;
- for (set ::const_iterator it = newset.begin ();
+ for (set ::const_iterator it = newset.begin ();
it != newset.end (); ++it)
{
setlist->add (*it);
@@ -914,6 +851,27 @@
}
+static YCPValue
+l_isempty(const YCPList& l)
+{
+ /**
+ * @builtin isempty
+ * @id isempty-list
+ * @short Returns whether the list <tt>l</tt> is empty.
+ * @param list l List
+ * @return boolean Emptiness of list <tt>l</tt>
+ *
+ * @description
+ * Notice that the list <tt>l</tt> must not be nil.
+ *
+ * @usage isempty([]) -> true
+ * @usage isempty([19, 29]) -> false
+ */
+
+ return YCPBoolean(l->isEmpty());
+}
+
+
// parameter is YCPValue because we accept 'nil'
static YCPValue
l_size (const YCPValue &list)
@@ -949,11 +907,14 @@
* @short Removes element from a list
* @param list LIST
* @param integer e element index
- * @return list Returns nil if the index is invalid.
+ * @return list Returns unchanged list if the index is invalid.
* @description
* Removes the <tt>i</tt>'th value from a list. The first value has the
* index 0. The call remove ([1,2,3], 1) thus returns [1,3].
*
+ * The yast2-core version < 2.17.16 returns nil if the key is invalid. This behavior
+ * has changed in version 2.17.16 to return unchanged list.
+ *
* @usage remove ([1, 2], 0) -> [2]
*/
@@ -975,7 +936,7 @@
if (idx < 0 || idx >= ret->size ())
{
ycp2error ("Index %s for remove () out of range", toString (idx).c_str ());
- return YCPNull ();
+ return ret;
}
ret->remove (idx);
@@ -1072,9 +1033,9 @@
SymbolEntryPtr s = sym->asEntry()->entry();
YCPValue ret = YCPVoid();
- for (int i=0; i < list->size(); i++)
+ for (YCPList::const_iterator it = list->begin(); it != list->end(); ++it)
{
- s->setValue (list->value (i));
+ s->setValue(*it);
ret = expr->evaluate ();
if (ret.isNull())
@@ -1093,6 +1054,44 @@
static YCPValue
+l_reduce_helper(const YCPSymbol &x, const YCPSymbol &y, const YCPValue &initial,
+ const YCPList::const_iterator &first, const YCPList::const_iterator &last,
+ const YCPCode &expr)
+{
+ SymbolEntryPtr xs = x->asEntry()->entry();
+ SymbolEntryPtr ys = y->asEntry()->entry();
+
+ YCPValue ret = initial;
+
+ for (YCPList::const_iterator it = first; it != last; ++it)
+ {
+ xs->setValue(ret);
+ ys->setValue(*it);
+
+ YCPValue tmp = expr->evaluate();
+ if (tmp.isNull())
+ {
+ ycp2error("Bad 'reduce' expression %s", expr->toString().c_str());
+ continue;
+ }
+ if (tmp->isVoid())
+ {
+ ycp2error("The expression for 'reduce' returned 'nil'");
+ continue;
+ }
+ if (tmp->isBreak())
+ {
+ break;
+ }
+
+ ret = tmp;
+ }
+
+ return ret;
+}
+
+
+static YCPValue
l_reduce1 (const YCPSymbol &x, const YCPSymbol &y, const YCPList &list, const YCPCode &expr)
{
/**
@@ -1115,50 +1114,20 @@
* the list must not be empty.
*
* @usage list::reduce (integer x, integer y, [2, 4, 6], { return x < y ? x : y; }) -> 2
- * @usage list::reduce (integer x, integer y, [2, 4, 6], { return x < y ? x : y; }) -> 6
+ * @usage list::reduce (integer x, integer y, [2, 4, 6], { return x > y ? x : y; }) -> 6
*/
- if (list.isNull())
- {
- return YCPNull();
- }
-
- if (list->size() < 1)
+ if (list->isEmpty())
{
- ycp2error("Empty list %s for 'reduce'", list->toString().c_str());
+ ycp2error("Empty list for 'reduce'");
return YCPNull();
}
- SymbolEntryPtr xs = x->asEntry()->entry();
- SymbolEntryPtr ys = y->asEntry()->entry();
-
- YCPValue ret = list->value(0);
-
- for (int i = 1; i < list->size(); i++)
- {
- xs->setValue(ret);
- ys->setValue(list->value(i));
-
- YCPValue tmp = expr->evaluate();
- if (tmp.isNull())
- {
- ycp2error("Bad 'reduce' expression %s", expr->toString().c_str());
- continue;
- }
- if (tmp->isVoid())
- {
- ycp2error("The expression for 'reduce' returned 'nil'");
- continue;
- }
- if (tmp->isBreak())
- {
- break;
- }
+ const YCPList::const_iterator initial = list->begin();
+ const YCPList::const_iterator first = initial + 1;
+ const YCPList::const_iterator last = list->end();
- ret = tmp;
- }
-
- return ret;
+ return l_reduce_helper(x, y, *initial, first, last, expr);
}
@@ -1175,7 +1144,7 @@
* @param list<flex2> list
* @param block<flex1> expression
* @return flex1
- *
+ *
* @description
* Apply expression cumulatively to the values of the list, from left to
* right, to reduce the list to a single value. See
@@ -1192,41 +1161,10 @@
* @usage list::reduce (term t, float f, `item(`id(`dummy)), [3.14, 2.71], { return add(t, tostring(f)); }) -> `item (`id (`dummy), "3.14", "2.71")
*/
- if (list.isNull())
- {
- return YCPNull();
- }
-
- SymbolEntryPtr xs = x->asEntry()->entry();
- SymbolEntryPtr ys = y->asEntry()->entry();
-
- YCPValue ret = initial;
-
- for (int i = 0; i < list->size(); i++)
- {
- xs->setValue(ret);
- ys->setValue(list->value(i));
-
- YCPValue tmp = expr->evaluate();
- if (tmp.isNull())
- {
- ycp2error("Bad 'reduce' expression %s", expr->toString().c_str());
- continue;
- }
- if (tmp->isVoid())
- {
- ycp2error("The expression for 'reduce' returned 'nil'");
- continue;
- }
- if (tmp->isBreak())
- {
- break;
- }
-
- ret = tmp;
- }
+ const YCPList::const_iterator first = list->begin();
+ const YCPList::const_iterator last = list->end();
- return ret;
+ return l_reduce_helper(x, y, initial, first, last, expr);
}
@@ -1264,7 +1202,7 @@
{ "find", "flex (variable <flex>, const list <flex>, const block <boolean>)", (void *)l_find, DECL_SYMBOL|DECL_FLEX },
{ "prepend", "list <flex> (const list <flex>, const flex)", (void *)l_prepend, DECL_FLEX },
{ "contains", "boolean (const list <flex>, const flex)", (void *)l_contains, DECL_FLEX },
- { "setcontains","boolean (list <flex>, const flex)", (void *)l_setcontains, DECL_FLEX },
+ { "setcontains","boolean (const list <flex>, const flex)", (void *)l_setcontains, DECL_FLEX },
{ "union", "list <any> (const list <any>, const list <any>)", (void *)l_unionlist },
{ "+", "list <flex> (const list <flex>, const list <flex>)", (void *)l_unionlist, DECL_FLEX },
{ "merge", "list <any> (const list <any>, const list <any>)", (void *)l_mergelist },
@@ -1283,6 +1221,7 @@
{ "add", "list <flex> (const list <flex>, const flex)", (void *)l_add, DECL_FLEX },
{ "+", "list <flex> (const list <flex>, const flex)", (void *)l_add, DECL_FLEX },
{ "+", "list <any> (const list <any>, any)", (void *)l_add },
+ { "isempty", "boolean (const list <any>)", (void *)l_isempty },
{ "size", "integer (const list <any>)", (void *)l_size, DECL_NIL },
{ "remove", "list <flex> (const list <flex>, const integer)", (void *)l_remove, DECL_FLEX },
{ "select", "flex (const list <flex>, integer, flex)", (void *)l_select, DECL_NIL|DECL_FLEX },
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinMap.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinMap.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinMap.cc Thu Jan 29 08:58:52 2009
@@ -62,8 +62,7 @@
return YCPNull ();
}
- YCPValue tmp = map->value (value);
- return YCPBoolean (!tmp.isNull ());
+ return YCPBoolean(map->hasKey(value));
}
@@ -96,10 +95,10 @@
SymbolEntryPtr k = key->asEntry()->entry();
SymbolEntryPtr v = value->asEntry()->entry();
- for (YCPMapIterator pos = map->begin (); pos != map->end (); ++pos)
+ for (YCPMap::const_iterator pos = map->begin(); pos != map->end(); ++pos)
{
- k->setValue (pos.key());
- v->setValue (pos.value());
+ k->setValue (pos->first);
+ v->setValue (pos->second);
YCPValue v = expr->evaluate ();
@@ -120,7 +119,7 @@
}
if (v->asBoolean ()->value ())
{
- ret->add (pos.key (), pos.value ());
+ ret->add(pos->first, pos->second);
}
}
@@ -165,10 +164,10 @@
SymbolEntryPtr k = key->asEntry()->entry();
SymbolEntryPtr v = value->asEntry()->entry();
- for (YCPMapIterator pos = map->begin (); pos != map->end (); ++pos)
+ for (YCPMap::const_iterator pos = map->begin (); pos != map->end (); ++pos)
{
- k->setValue (pos.key());
- v->setValue (pos.value());
+ k->setValue (pos->first);
+ v->setValue (pos->second);
YCPValue curr_value = expr->evaluate ();
@@ -180,8 +179,8 @@
}
expr_map = curr_value->asMap();
- YCPMapIterator it = expr_map->begin();
- ret->add (it.key(), it.value());
+ YCPMap::const_iterator it = expr_map->begin();
+ ret->add(it->first, it->second);
}
else
{
@@ -227,10 +226,10 @@
SymbolEntryPtr k = key->asEntry()->entry();
SymbolEntryPtr v = value->asEntry()->entry();
- for (YCPMapIterator pos = map->begin (); pos != map->end (); pos++)
+ for (YCPMap::const_iterator pos = map->begin(); pos != map->end(); ++pos)
{
- k->setValue (pos.key());
- v->setValue (pos.value());
+ k->setValue (pos->first);
+ v->setValue (pos->second);
YCPValue v = expr->evaluate();
@@ -280,9 +279,9 @@
{
YCPMap map = (m == 0 ? map1 : map2);
- for (YCPMapIterator pos = map->begin (); pos != map->end (); pos++)
+ for (YCPMap::const_iterator pos = map->begin(); pos != map->end(); ++pos)
{
- newmap->add (pos.key (), pos.value ());
+ newmap->add(pos->first, pos->second);
}
}
@@ -361,6 +360,27 @@
}
+static YCPValue
+m_isempty(const YCPMap& m)
+{
+ /**
+ * @builtin isempty
+ * @id isempty-map
+ * @short Returns whether the map <tt>m</tt> is empty.
+ * @param map m Map
+ * @return boolean Emptiness of map <tt>m</tt>
+ *
+ * @description
+ * Notice that the map <tt>m</tt> must not be nil.
+ *
+ * @usage isempty($[]) -> true
+ * @usage isempty($[ `host : "pandora" ]) -> false
+ */
+
+ return YCPBoolean(m->isEmpty());
+}
+
+
// parameter is YCPValue because we accept 'nil'
static YCPValue
m_size (const YCPValue &map)
@@ -418,10 +438,10 @@
SymbolEntryPtr v = val->asEntry()->entry();
YCPValue ret = YCPVoid();
- for (YCPMapIterator pos = map->begin(); pos != map->end(); ++pos)
+ for (YCPMap::const_iterator pos = map->begin(); pos != map->end(); ++pos)
{
- k->setValue (pos.key());
- v->setValue (pos.value());
+ k->setValue (pos->first);
+ v->setValue (pos->second);
ret = expr->evaluate ();
if (ret.isNull())
@@ -478,13 +498,16 @@
*
* @description
* Remove the value with the key <tt>KEY</tt> from a map. Returns
- * nil if the key is invalid.
+ * unchanged map if the key is invalid.
+ *
+ * The yast2-core version < 2.17.16 returns nil if the key is invalid. This behavior
+ * has changed in version 2.17.16 to return unchanged map.
*
* @param map MAP
* @param any KEY
* @return map
*
- * @usage remove($[1:2], 0) -> nil
+ * @usage remove($[1:2], 0) -> $[1:2]
* @usage remove($[1:2], 1) -> $[]
* @usage remove ($[1:2, 3:4], 1) -> $[3:4]
*/
@@ -500,10 +523,10 @@
YCPMap ret = map;
- if(map->value (key).isNull ())
+ if (!map->hasKey(key))
{
ycp2error ( "Key %s for remove () does not exist", key->toString ().c_str ());
- return YCPNull ();
+ return ret;
}
ret->remove (key);
@@ -544,6 +567,7 @@
{ "+", "map (const map , const map )", (void *)m_unionmap },
{ "add", "map (const map , const flex1, const flex2)", (void *)m_addmap, DECL_FLEX },
{ "change", "map (const map , const flex1, const flex2)", (void *)m_changemap,DECL_FLEX|DECL_DEPRECATED },
+ { "isempty", "boolean (const map )", (void *)m_isempty },
{ "size", "integer (const map )", (void *)m_size, DECL_NIL },
{ "foreach","flex1 (variable <flex2>, variable <flex3>, const map , const block <flex1>)", (void *)m_foreach, DECL_LOOP|DECL_SYMBOL|DECL_FLEX },
{ "tomap", "map (const any)", (void *)m_tomap, DECL_FLEX },
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinMisc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinMisc.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinMisc.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinMisc.cc Thu Jan 29 08:58:52 2009
@@ -35,6 +35,7 @@
#include "ycp/StaticDeclaration.h"
#include "ycp/y2log.h"
+#include "y2util/y2changes.h"
#include "ycp/ExecutionEnvironment.h"
extern StaticDeclaration static_declarations;
@@ -614,6 +615,64 @@
}
+static YCPValue
+Y2UserItem (const YCPString & format, const YCPList & args)
+{
+ /**
+ * @builtin y2useritem
+ * @short Log an user-level system message to the y2changes
+ *
+ * @param string FORMAT
+ * @param any PAR1
+ * @param any PAR2
+ * @param any ...
+ * @return void
+ * @see sformat
+ *
+ * @usage y2useritem("Executing reboot")
+ */
+
+ YCPString arg = s_sformat (format, args);
+ if (arg.isNull () || !arg->isString ())
+ {
+ return YCPNull ();
+ }
+
+ y2useritem ("%s", arg->value().c_str());
+
+ return YCPVoid();
+}
+
+
+static YCPValue
+Y2UserNote (const YCPString & format, const YCPList & args)
+{
+ /**
+ * @builtin y2usernote
+ * @short Log an user-level addional message to the y2changes
+ *
+ * @param string FORMAT
+ * @param any PAR1
+ * @param any PAR2
+ * @param any ...
+ * @return void
+ * @see sformat
+ *
+ * @usage y2usernote("Starting module Bee")
+ */
+
+ YCPString arg = s_sformat (format, args);
+ if (arg.isNull () || !arg->isString ())
+ {
+ return YCPNull ();
+ }
+
+ y2usernote ("%s", arg->value().c_str());
+
+ return YCPVoid();
+}
+
+
YCPBuiltinMisc::YCPBuiltinMisc ()
{
// must be static, registerDeclarations saves a pointer to it!
@@ -643,6 +702,9 @@
{ "y2error", "void (integer, string, ...)", (void *)Y2FError, DECL_NIL|DECL_WILD },
{ "y2security", "void (integer, string, ...)", (void *)Y2FSecurity, DECL_NIL|DECL_WILD },
{ "y2internal", "void (integer, string, ...)", (void *)Y2FInternal, DECL_NIL|DECL_WILD },
+ // user-level logging
+ { "y2useritem", "void (string, ...)", (void *)Y2UserItem, DECL_NIL|DECL_WILD|DECL_FORMATTED },
+ { "y2usernote", "void (string, ...)", (void *)Y2UserNote, DECL_NIL|DECL_WILD|DECL_FORMATTED },
{ 0 }
};
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinString.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinString.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinString.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinString.cc Thu Jan 29 08:58:52 2009
@@ -35,7 +35,6 @@
#include
#include
#include
-#include <iostream>
#include <string>
using std::string;
@@ -58,6 +57,27 @@
static YCPValue
+s_isempty(const YCPString& s)
+{
+ /**
+ * @builtin isempty
+ * @id isempty-string
+ * @short Returns whether the string <tt>s</tt> is empty.
+ * @param string s String
+ * @return boolean Emptiness of string <tt>s</tt>
+ *
+ * @description
+ * Notice that the string <tt>s</tt> must not be nil.
+ *
+ * @usage isempty("") -> true
+ * @usage isempty("test") -> false
+ */
+
+ return YCPBoolean(s->isEmpty());
+}
+
+
+static YCPValue
s_size (const YCPString &s)
{
/**
@@ -331,6 +351,114 @@
static YCPValue
+s_lsubstring1 (const YCPString &s, const YCPInteger &i1)
+{
+ /**
+ * @builtin lsubstring
+ * @id lsubstring-rest
+ * @short Extracts a substring in UTF-8 encoded string
+ *
+ * @description
+ * Extracts a substring of the string <tt>STRING</tt>, starting at
+ * <tt>OFFSET</tt> after the first one with length of at most
+ * <tt>LENGTH</tt>. <tt>OFFSET</tt> starts with 0. This method uses UTF-8 encoding.
+ *
+ * @param string STRING
+ * @param integer OFFSET
+ * @param integer LENGTH
+ * @return string
+ * @usage substring ("some text", 5) -> "text"
+ * @usage substring ("some text", 42) -> ""
+ */
+
+ if (s.isNull () || i1.isNull())
+ return YCPNull ();
+
+ string lss = s->value ();
+ wstring ss;
+
+ if( ! utf82wchar( lss, &ss ) )
+ {
+ y2error( "Unable to recode string '%s' to UTF-8", lss.c_str() );
+ return YCPNull ();
+ }
+
+ string::size_type start = i1->value ();
+
+ if (start > ss.size ())
+ {
+ ycp2error ("Substring index out of range");
+ return YCPString ("");
+ }
+
+ ss = ss.substr ((wstring::size_type) start, wstring::npos);
+
+ if( !wchar2utf8( ss, &lss ) )
+ {
+ y2error( "Unable to recode result string '%ls' from UTF-8", ss.c_str() );
+ return YCPNull ();
+ }
+
+ return YCPString(lss);
+}
+
+
+static YCPValue
+s_lsubstring2 (const YCPString &s, const YCPInteger &i1, const YCPInteger &i2)
+{
+ /**
+ * @builtin lsubstring
+ * @id lsubstring-length
+ * @short Extracts a substring in UTF-8 encoded string
+ *
+ * @description
+ * Extracts a substring of the string <tt>STRING</tt>, starting at
+ * <tt>OFFSET</tt> after the first one with length of at most
+ * <tt>LENGTH</tt>. <tt>OFFSET</tt> starts with 0. This method uses UTF-8 encoding.
+ *
+ * @param string STRING
+ * @param integer OFFSET
+ * @param integer LENGTH
+ * @return string
+ * @usage lsubstring ("some text", 5, 2) -> "te"
+ * @usage lsubstring ("some text", 42, 2) -> ""
+ * @usage lsubstring("123456789", 2, 3) -> "345"
+ */
+
+ if (s.isNull () || i1.isNull() || i2.isNull ())
+ return YCPNull ();
+
+ string lss = s->value ();
+ wstring ss;
+
+ if( ! utf82wchar( lss, &ss ) )
+ {
+ y2error( "Unable to recode string '%s' to UTF-8", lss.c_str() );
+ return YCPNull ();
+ }
+
+ string::size_type start = i1->value ();
+ string::size_type length = i2->value ();
+
+ if (start > ss.size ())
+ {
+ ycp2error ("Substring index out of range");
+ return YCPString ("");
+ }
+
+ ss = ss.substr (start, length);
+
+ if( !wchar2utf8( ss, &lss ) )
+ {
+ y2error( "Unable to recode result string '%ls' from UTF-8", ss.c_str() );
+ return YCPNull ();
+ }
+
+ return YCPString(lss);
+}
+
+
+static YCPValue
s_search (const YCPString &s1, const YCPString &s2)
{
/**
@@ -1380,6 +1508,7 @@
{ "tostring", "string (any)", (void *)s_tostring },
{ "tohexstring", "string (integer)", (void *)s_tohexstring1 },
{ "tohexstring", "string (integer, integer)", (void *)s_tohexstring2 },
+ { "isempty", "boolean (string)", (void *)s_isempty },
{ "size", "integer (string)", (void *)s_size },
{ "find", "integer (string, string)", (void *)s_find, DECL_DEPRECATED },
{ "search", "integer (string, string)", (void *)s_search },
@@ -1407,6 +1536,8 @@
{ "dgettext", "string (string, string)", (void *)s_dgettext},
{ "dngettext", "string (string, string, string, integer)", (void *)s_dngettext},
{ "dpgettext", "string (string, string, string)", (void *)s_dpgettext},
+ { "lsubstring", "string (string, integer)", (void *)s_lsubstring1 },
+ { "lsubstring", "string (string, integer, integer)", (void *)s_lsubstring2 },
{ 0 }
};
Modified: branches/tmp/lslezak/core/libycp/src/YCPBuiltinTerm.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPBuiltinTerm.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPBuiltinTerm.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPBuiltinTerm.cc Thu Jan 29 08:58:52 2009
@@ -232,6 +232,9 @@
* remove which allowed 'remove(`term(1,2,3), 0) = [1,2,3]'
* Use 'argsof (term) -> list' for this kind of transformation.)
*
+ * The yast2-core version < 2.17.16 returns nil if the index is invalid. This behavior
+ * has changed in version 2.17.16 to return unchanged term.
+ *
* @param term TERM
* @param integer i
* @return term
@@ -250,7 +253,7 @@
if (idx <= 0 || idx > args->size ())
{
ycp2error ("Index %s for remove () out of range", toString (idx).c_str ());
- return YCPNull ();
+ return term;
}
args->remove (idx-1);
Modified: branches/tmp/lslezak/core/libycp/src/YCPList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPList.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPList.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPList.cc Thu Jan 29 08:58:52 2009
@@ -10,10 +10,11 @@
| (C) SuSE GmbH |
\----------------------------------------------------------------------/
- File: YCPList.cc
+ File: YCPList.cc
Authors: Mathias Kettner
Klaus Kaempf
+ Arvin Schnell
Maintainer: Klaus Kaempf
/-*/
@@ -67,6 +68,13 @@
void
+YCPListRep::push_back(const YCPValue& value)
+{
+ elements.push_back(value);
+}
+
+
+void
YCPListRep::set (const int i, const YCPValue& value)
{
if (i < 0)
@@ -102,41 +110,24 @@
bool YCPListRep::contains (const YCPValue& value) const
{
- for (vector <YCPValue>::const_iterator it = elements.begin ();
- it != elements.end (); it++)
- {
- if ((*it)->equal (value))
- return true;
- }
-
- return false;
-}
-
-
-static bool compareYCP (const YCPValue& y1, const YCPValue& y2)
-{
- return (y1->compare(y2)) == YO_LESS;
+ return find_if(begin(), end(), bind2nd(ycp_equal_to(), value)) != end();
}
void
YCPListRep::sortlist()
{
- std::sort (elements.begin (), elements.end (), compareYCP);
+ std::sort(elements.begin(), elements.end(), ycp_less());
}
-static bool lcompareYCP( const YCPValue& y1, const YCPValue& y2 )
+void
+YCPListRep::lsortlist()
{
- return y1->compare(y2, true) == YO_LESS;
+ std::sort(elements.begin(), elements.end(), ycp_less(true));
}
-void YCPListRep::lsortlist()
-{
- std::sort (elements.begin (), elements.end (), lcompareYCP);
-}
-
void
YCPListRep::fsortlist(const YCPCodeCompare& cmp)
{
@@ -193,6 +184,20 @@
}
+YCPListRep::const_iterator
+YCPListRep::begin() const
+{
+ return elements.begin();
+}
+
+
+YCPListRep::const_iterator
+YCPListRep::end() const
+{
+ return elements.end();
+}
+
+
YCPOrder
YCPListRep::compare(const YCPList& l) const
{
Modified: branches/tmp/lslezak/core/libycp/src/YCPMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/libycp/src/YCPMap.cc?rev=55132&r1=55131&r2=55132&view=diff
==============================================================================
--- branches/tmp/lslezak/core/libycp/src/YCPMap.cc (original)
+++ branches/tmp/lslezak/core/libycp/src/YCPMap.cc Thu Jan 29 08:58:52 2009
@@ -12,7 +12,8 @@
File: YCPMap.cc
- Author: Mathias Kettner
+ Authors: Mathias Kettner
+ Arvin Schnell
Maintainer: Klaus Kaempf
/-*/
@@ -56,12 +57,22 @@
ycp2error ("Only integer, string, or symbol constant allowed as key in map");
return;
}
- YCPValueYCPValueMap::iterator pos = stl_map.find( key );
- if ( pos == stl_map.end() )
- stl_map.insert( YCPValueYCPValueMap::value_type( key, value ) );
- else
+ // Note: 'stl_map[key] = value' would create a temporary object using the
+ // default constructor for YCPValue. See Scott Meyers, Effective STL, Item
+ // 24.
+
+ YCPMap::iterator pos = stl_map.lower_bound(key);
+ if (pos != stl_map.end() && !YCPMap::key_compare()(key, pos->first))
+ {
pos->second = value;
+ }
+ else
+ {
+ // pos is just a hint but can avoid a second search through the map
+ stl_map.insert(pos, YCPMap::value_type(key, value));
+ }
+
}
@@ -79,9 +90,9 @@
YCPMap newmap;
- for (YCPMapIterator pos = begin(); pos != end(); ++pos )
+ for (YCPMap::const_iterator pos = begin(); pos != end(); ++pos)
{
- newmap->add( pos.key(), pos.value() );
+ newmap->add(pos->first, pos->second);
}
newmap->add( key, value );
@@ -106,13 +117,20 @@
{
YCPMapRep* newmap = new YCPMapRep ();
- for (YCPMapIterator pos = begin(); pos != end(); ++pos )
- newmap->add (pos.key(), pos.value());
+ for (YCPMap::const_iterator pos = begin(); pos != end(); ++pos)
+ newmap->add(pos->first, pos->second);
return newmap;
}
+bool
+YCPMapRep::isEmpty() const
+{
+ return stl_map.empty();
+}
+
+
long
YCPMapRep::size() const
{
@@ -120,13 +138,22 @@
}
+bool
+YCPMapRep::hasKey(const YCPValue& key) const
+{
+ return stl_map.find(key) != stl_map.end();
+}
+
+
YCPValue
YCPMapRep::value(const YCPValue& key) const
{
- YCPMapIterator pos = stl_map.find( key );
+ YCPMap::const_iterator pos = stl_map.find(key);
- if ( pos != end() ) return pos.value();
- else return YCPNull();
+ if (pos != end())
+ return pos->second;
+ else
+ return YCPNull();
}
@@ -151,16 +178,16 @@
else
{
// equal length ==> pairwise comparison
- for( YCPMapIterator pos_this = begin(), pos_m = m->begin();
+ for( YCPMap::const_iterator pos_this = begin(), pos_m = m->begin();
pos_this != end(), pos_m != m->end();
++pos_this, ++pos_m )
{
// compare keys
- order = pos_this.key()->compare( pos_m.key() );
+ order = pos_this->first->compare(pos_m->first);
if ( order == YO_LESS || order == YO_GREATER ) return order;
// equal keys ==> compare values
- order = pos_this.value()->compare( pos_m.value() );
+ order = pos_this->second->compare(pos_m->second);
if ( order == YO_LESS || order == YO_GREATER ) return order;
}
@@ -177,25 +204,18 @@
{
string s = "$[";
- for(YCPMapIterator pos = begin(); pos != end(); ++pos )
+ for (YCPMap::const_iterator pos = begin(); pos != end(); ++pos)
{
if ( pos != begin() ) s += ", ";
- s += pos.key()->toString()
+ s += pos->first->toString()
+ ":"
- + ((pos.value().isNull()) ? "(null)" : pos.value()->toString());
+ + ((pos->second.isNull()) ? "(null)" : pos->second->toString());
}
return s + "]";
}
-YCPMapIterator
-YCPMapRep::findKey(const YCPValue& key) const
-{
- return stl_map.find( key );
-}
-
-
YCPValueType
YCPMapRep::valuetype() const
{
@@ -210,11 +230,11 @@
YCPMapRep::toStream (std::ostream & str) const
{
Bytecode::writeInt32 (str, stl_map.size());
- for(YCPMapIterator pos = begin(); pos != end(); ++pos )
+ for (YCPMap::const_iterator pos = begin(); pos != end(); ++pos)
{
- if (!Bytecode::writeValue (str, pos.key()))
+ if (!Bytecode::writeValue (str, pos->first))
break;
- if (!Bytecode::writeValue (str, pos.value()))
+ if (!Bytecode::writeValue (str, pos->second))
break;
}
return str;
@@ -225,11 +245,11 @@
YCPMapRep::toXml (std::ostream & str, int indent ) const
{
str << "