void * ruby_options(int argc, char **argv) { #if MACRUBY_STATIC printf("command-line options are not supported in MacRuby static\n"); abort(); #else return ruby_process_options(argc, argv); #endif }
/*! Processes command line arguments and compiles the Ruby source to execute. * * This function does: * \li Processes the given command line flags and arguments for ruby(1) * \li compiles the source code from the given argument, -e or stdin, and * \li returns the compiled source as an opaque pointer to an internal data structure * * @return an opaque pointer to the compiled source or an internal special value. * @sa ruby_executable_node(). */ void * ruby_options(int argc, char **argv) { int state; void *volatile iseq = 0; ruby_init_stack((void *)&iseq); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv)); } else { rb_clear_trace_func(); state = error_handle(state); iseq = (void *)INT2FIX(state); } POP_TAG(); return iseq; }
void * ruby_options(int argc, char **argv) { int state; void *tree = 0; Init_stack((void *)&tree); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(GET_THREAD(), tree = ruby_process_options(argc, argv)); } else { rb_clear_trace_func(); state = error_handle(state); tree = (void *)INT2FIX(state); } POP_TAG(); return tree; }
int main(void) { char *argv_raw[] = { "milter-manager", "-e", "''" }; int argc; char **argv; argc = sizeof(argv_raw) / sizeof(char *); argv = argv_raw; ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); return ruby_run_node(ruby_process_options(argc, argv)); } }
void startup(const char* script_name) { if(running) { return; } int fake_argc = 0; char *fake_args[fake_argc]; char **fake_argv = fake_args; ruby_sysinit(&fake_argc, &fake_argv); // Initialize Ruby itself RUBY_INIT_STACK; ruby_init(); ruby_init_loadpath(); //Init_prelude(); //ruby_init_gems(); // To load prelude.rb static char* args[] = { "ruby", "/dev/null" }; ruby_process_options(2, args); // Load Ruby encodings, otherwise we'll get all kinds of "Unitialized // constanct Encoding::UTF-7", etc. everywhere. rb_enc_find_index("encdb"); VALUE gem; gem = rb_define_module("Gem"); rb_const_set(gem, rb_intern("Enable"), Qtrue); rb_require("rubygems"); ruby_script((char*)script_name); running = true; }
int proxenet_ruby_initialize_vm(plugin_t* plugin) { static char* rArgs[2] = { "ruby", "/dev/null" }; interpreter_t *interpreter; VALUE rRet; interpreter = plugin->interpreter; /* checks */ if (interpreter->ready) return 0; #ifdef DEBUG xlog_ruby(LOG_DEBUG, "Initializing Ruby VM version %s\n", _RUBY_VERSION_); #endif /* init vm */ ruby_init(); /* * The hack of calling ruby_process_options() with /dev/null allows to simply (in one call) * init all the structures and encoding params by the vm * Details: http://rxr.whitequark.org/mri/source/ruby.c#1915 */ rRet = (VALUE)ruby_process_options(2, rArgs); if (rRet == Qnil) { xlog_ruby(LOG_ERROR, "Error on ruby_process_options(): %#x\n", rRet); proxenet_ruby_print_last_exception(); return -1; } interpreter->vm = (void*) rb_mKernel; interpreter->ready = true; return 0; }