[seed] Add os.uname



commit 814279e79b415c531dd4523e5bfad46dc4e527e5
Author: Robert Carr <racarr mireia (none)>
Date:   Mon Apr 13 22:18:23 2009 -0400

    Add os.uname
---
 modules/os/os.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/modules/os/os.c b/modules/os/os.c
index 89de514..59580a2 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -6,6 +6,7 @@
 #include <string.h>
 
 #include <sys/stat.h>
+#include <sys/utsname.h>
 
 #include <seed.h>
 
@@ -462,6 +463,35 @@ seed_os_umask (SeedContext ctx,
   return seed_value_from_long (ctx, umask(arg), exception);
 }
 
+SeedValue
+seed_os_uname (SeedContext ctx,
+	       SeedObject function,
+	       SeedObject this_object,
+	       size_t argument_count,
+	       const SeedValue arguments[], 
+	       SeedException * exception)
+{
+  SeedValue elements[5], ret;
+  guint c;
+  struct utsname name;
+  
+  if (argument_count != 0)
+    {
+      EXPECTED_EXCEPTION("os.uname", "no arguments");
+    }
+  c = uname (&name);
+  // TODO: Do something with c
+  elements[0] = seed_value_from_string (ctx, name.sysname, exception);
+  elements[1] = seed_value_from_string (ctx, name.nodename, exception);
+  elements[2] = seed_value_from_string (ctx, name.release, exception);
+  elements[3] = seed_value_from_string (ctx, name.version, exception);
+  elements[4] = seed_value_from_string (ctx, name.machine, exception);
+  ret = seed_make_array (ctx, elements, 5, exception);
+  
+  
+  return ret;
+}
+
 seed_static_function os_funcs[] = {
   {"chdir", seed_os_chdir, 0},
   {"fchdir", seed_os_fchdir, 0},
@@ -483,7 +513,8 @@ seed_static_function os_funcs[] = {
   {"seteuid", seed_os_setegid, 0},
   {"setuid", seed_os_setuid, 0},
   {"strerror", seed_os_strerror, 0},
-  {"umask", seed_os_umask, 0}
+  {"umask", seed_os_umask, 0},
+  {"uname", seed_os_uname, 0}
 };
 
 SeedObject



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