[yast-commit] r40699 - in /trunk/core: VERSION libycp/src/YCPBuiltinMisc.cc package/yast2-core.changes

Author: juhliarik Date: Mon Sep 3 14:09:51 2007 New Revision: 40699 URL: http://svn.opensuse.org/viewcvs/yast?rev=40699&view=rev Log: added new function getenv() Modified: trunk/core/VERSION trunk/core/libycp/src/YCPBuiltinMisc.cc trunk/core/package/yast2-core.changes Modified: trunk/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=40699&r1=40698&r... ============================================================================== --- trunk/core/VERSION (original) +++ trunk/core/VERSION Mon Sep 3 14:09:51 2007 @@ -1 +1 @@ -2.15.9 +2.15.10 Modified: trunk/core/libycp/src/YCPBuiltinMisc.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPBuiltinMisc.cc... ============================================================================== --- trunk/core/libycp/src/YCPBuiltinMisc.cc (original) +++ trunk/core/libycp/src/YCPBuiltinMisc.cc Mon Sep 3 14:09:51 2007 @@ -24,6 +24,7 @@ #include <netinet/in.h> #include <sys/socket.h> #include <arpa/inet.h> +#include <errno.h> #include "ycp/YCPBuiltinMisc.h" #include "ycp/YCPBoolean.h" @@ -140,6 +141,86 @@ } +static YCPBoolean +Setenv2 (const YCPString & name, const YCPString & value, const YCPBoolean & overwrite) +{ + /** + * @builtin setenv + * @short Change or add an environment variable + * @description + * The setenv() function adds the variable to the + * environment with the value. If variable exist + * the value is changed. + * @param string variable + * @param string value + * @param boolean overwrite + * @return boolean + * @id setenv_2 + * @usage setenv("PATH", "/home/user", true) + */ + //3rd argument (1) means that value will be overwrite if it exist + int ret = setenv(name->value().c_str(), value->value().c_str(), (overwrite->value() ? 1:0) ); + if (ret == 0) { + return YCPBoolean(true); + } else { + ycp2error ("[Setenv1] failed %s",strerror(errno)); + return YCPBoolean(false); + } +} + + +static YCPBoolean +Setenv1 (const YCPString & name, const YCPString & value) +{ + /** + * @builtin setenv + * @short Change or add an environment variable + * @description + * The setenv() function adds the variable to the + * environment with the value. If variable exist + * the value is changed. + * @param string variable + * @param string value + * @return boolean + * @id setenv_1 + * @usage setenv("PATH", "/home/user") + */ + //3rd argument (1) means that value will be overwrite if it exist + + return Setenv2(name, value, YCPBoolean(true)); + +} + + + +/* +static YCPString +Getenv (const YCPString & name) +{ + ** + * @builtin setenv + * @short Change or add an environment variable + * @description + * The getenv(variable) function returns the value of variable from + * environment. If variable doesn't exist + * the value is NULL. + * @param string name + * @return string value + * @id getenv_1 + * @usage getenv("name") + * + + char *value = getenv(name->value().c_str()); + if (value) { + string ret (value); + return YCPString(ret); + } else { + return YCPNull(); + } + +} +*/ + static YCPValue Eval (const YCPValue & v) { @@ -518,6 +599,9 @@ { "time", "integer ()", (void *)Time }, { "sleep", "void (integer)", (void *)Sleep }, { "random", "integer (integer)", (void *)Random }, + { "setenv", "boolean (string,string)", (void *)Setenv1 }, + { "setenv", "boolean (string,string,boolean)", (void *)Setenv2 }, + //{ "getenv", "string (string)", (void *)Getenv }, //function exist in other module { "srandom", "integer ()", (void *)Srandom1 }, { "srandom", "void (integer)", (void *)Srandom2 }, { "eval", "flex (block <flex>)", (void *)Eval, DECL_NIL|DECL_FLEX }, Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?r... ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Mon Sep 3 14:09:51 2007 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon Sep 3 13:41:33 CEST 2007 - juhliarik@suse.cz + +- Added new function getenv(), #305163 +- 2.15.10 + +------------------------------------------------------------------- Tue Aug 21 15:57:24 CEST 2007 - mvidner@suse.cz - Fixed changing the value of table cells (#302042). -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
juhliarik@svn.opensuse.org