[seed] Add os.putenv



commit df566d56a8f03f522aa1c46071cb154e92d475f6
Author: Robert Carr <racarr mireia (none)>
Date:   Mon Apr 13 21:14:40 2009 -0400

    Add os.putenv
---
 modules/os/os.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/modules/os/os.c b/modules/os/os.c
index 0c4d096..a41cf1f 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -316,6 +316,33 @@ seed_os_getenv (SeedContext ctx,
   return ret;
 }
 
+SeedValue
+seed_os_putenv (SeedContext ctx,
+		SeedObject function,
+		SeedObject this_object,
+		size_t argument_count,
+		const SeedValue arguments[], 
+		SeedException * exception)
+{
+  gint ret;
+  gchar *name, *value, *arg;
+  
+  if (argument_count != 2)
+    {
+      EXPECTED_EXCEPTION("os.putenv", "2 arguments");
+    }
+  name = seed_value_to_string (ctx, arguments[0], exception);
+  value = seed_value_to_string (ctx, arguments[1], exception);
+  arg = g_strconcat (name, "=", value, NULL);
+  
+  ret = putenv (arg);
+  
+  g_free (name);
+  g_free (value);
+  
+  return seed_value_from_int (ctx, ret, exception);
+}
+
 seed_static_function os_funcs[] = {
   {"chdir", seed_os_chdir, 0},
   {"fchdir", seed_os_fchdir, 0},
@@ -330,7 +357,8 @@ seed_static_function os_funcs[] = {
   {"getpgrp", seed_os_getpgrp, 0},
   {"getpid", seed_os_getpid, 0},
   {"getppid", seed_os_getuid, 0},
-  {"getenv", seed_os_getenv, 0}
+  {"getenv", seed_os_getenv, 0},
+  {"putenv", seed_os_putenv, 0}
 };
 
 SeedObject



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]