1 static void Init_golf_prelude(void);
2 static void *goruby_options(int argc
, char **argv
);
3 static int goruby_run_node(void *arg
);
4 #define ruby_options goruby_options
5 #define ruby_run_node goruby_run_node
13 #define pipe(p) _pipe(p, 32L, _O_NOINHERIT)
14 #elif defined HAVE_UNISTD_H
18 RUBY_EXTERN
void *ruby_options(int argc
, char **argv
);
19 RUBY_EXTERN
int ruby_run_node(void*);
21 #include "golf_prelude.rbbin"
27 rb_provide("golf.so");
32 goruby_options(int argc
, char **argv
)
34 static const char cmd
[] = "END{require 'irb';IRB.start}";
38 if ((isatty(0) && isatty(1) && isatty(2)) && (pipe(rw
) == 0)) {
48 n
= write(rw
[1], cmd
, sizeof(cmd
) - 1);
50 ret
= n
> 0 ? ruby_options(argc
, argv
) : NULL
;
56 return ruby_options(argc
, argv
);
60 goruby_run_node(void *arg
)
63 if (ruby_executable_node(arg
, NULL
) &&
64 NIL_P(rb_protect(init_golf
, Qtrue
, &state
))) {
65 return state
== EXIT_SUCCESS
? EXIT_FAILURE
: state
;
67 return ruby_run_node(arg
);