ext/swift.h in swift-0.7.2 vs ext/swift.h in swift-0.8.0

- old
+ new

@@ -3,10 +3,13 @@ #include <dbic++.h> #include <ruby/ruby.h> #include <ruby/io.h> #include <stdint.h> +#include <unistd.h> +#include <sys/types.h> +#include <pwd.h> #define CONST_GET(scope, constant) rb_funcall(scope, rb_intern("const_get"), 1, rb_str_new2(constant)) #define TO_S(v) rb_funcall(v, rb_intern("to_s"), 0) #define CSTRING(v) RSTRING_PTR(TO_S(v)) @@ -24,11 +27,18 @@ } \ catch (std::bad_alloc &error) { \ rb_raise(rb_eNoMemError, "%s", error.what()); \ } + +// works without a controlling tty, getlogin() will fail when process is daemonized. +inline VALUE CURRENT_USER() { + struct passwd *ptr = getpwuid(getuid()); + return ptr ? rb_str_new2(ptr->pw_name) : rb_str_new2("root"); +} + #include "adapter.h" -#include "iostream.h" +#include "adapter_io.h" #include "query.h" #include "result.h" #include "statement.h" #include "request.h" #include "pool.h"