[macruby-changes] [4873] MacRuby/trunk/io.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Nov 2 16:46:15 PDT 2010


Revision: 4873
          http://trac.macosforge.org/projects/ruby/changeset/4873
Author:   lsansonetti at apple.com
Date:     2010-11-02 16:46:13 -0700 (Tue, 02 Nov 2010)
Log Message:
-----------
add Kernel#getpass method, which wraps the getpass(3) API

Modified Paths:
--------------
    MacRuby/trunk/io.c

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2010-11-02 23:28:36 UTC (rev 4872)
+++ MacRuby/trunk/io.c	2010-11-02 23:46:13 UTC (rev 4873)
@@ -4626,6 +4626,14 @@
     }
 }
 
+static VALUE
+rb_getpass(VALUE self, SEL sel, VALUE prompt)
+{
+    StringValue(prompt);
+    char *pwd = getpass(RSTRING_PTR(prompt));
+    return rb_str_new2(pwd);
+}
+
 void
 Init_IO(void)
 {
@@ -4882,4 +4890,7 @@
     sel_each_byte = sel_registerName("each_byte");
     sel_each_char = sel_registerName("each_char");
     sel_each_line = sel_registerName("each_line");
+
+    // MacRuby extensions:
+    rb_objc_define_module_function(rb_mKernel, "getpass", rb_getpass, 1);
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101102/d011aa0f/attachment.html>


More information about the macruby-changes mailing list