4 #if defined(MODULE_EMBED) 12 #define HAVE_SETPROCTITLE 1 19 #if defined(WITH_RUBYEMBED) 24 #define _RPMRUBY_INTERNAL 1 44 # if defined(MODULE_EMBED) 73 if (_rpmrubyPool == NULL) {
82 #if defined(WITH_RUBYEMBED) 85 static const char * rpmrubyInitStringIO =
"\ 87 $stdout = StringIO.new($result, \"w+\")\n\ 100 #if defined(WITH_RUBYEMBED) 101 static void loadModule(
void) {
102 const char librpmruby[] =
"rpmruby.so";
105 h = dlopen (librpmruby, RTLD_NOW|RTLD_GLOBAL);
109 "embedded ruby will not be available\n"),
110 librpmruby, dlerror());
112 else if(!((rpmrubyNew_p = dlsym(h,
"rpmrubyNew"))
113 && (rpmrubyRun_p = dlsym(h,
"rpmrubyRun")))) {
115 "embedded ruby will not be available\n"),
116 librpmruby, dlerror());
127 #if defined(WITH_RUBYEMBED) 128 if (!dlopened) loadModule();
129 if (dlopened)
return rpmrubyNew_p(av, flags);
132 static const char *_av[] = {
"rpmruby", NULL };
138 rpmruby ruby = (flags & 0x80000000)
144 # if defined(MODULE_EMBED) 147 ruby_init_loadpath();
149 ruby_script((
char *)av[0]);
150 rb_gv_set(
"$result", rb_str_new2(
""));
151 (void)
rpmrubyRun(ruby, rpmrubyInitStringIO, NULL);
157 #if defined(WITH_RUBYEMBED) 158 static int dlopened = 0;
159 static rpmruby (*rpmrubyNew_p) (
char ** av, uint32_t flags);
160 static rpmRC (*rpmrubyRun_p) (
rpmruby ruby,
const char * str,
const char ** resultp);
165 #if defined(WITH_RUBYEMBED) 166 if (dlopened)
return rpmrubyRun_p(ruby, str, resultp);
172 fprintf(stderr,
"==> %s(%p,%s,%p)\n", __FUNCTION__, ruby, str, resultp);
177 #if defined(MODULE_EMBED) 180 ruby->state = rb_eval_string_protect(str, &state);
187 *resultp = RSTRING_PTR(rb_gv_get(
"$result"));
rpmruby _rpmrubyI
Current (global) interpreter instance.
static rpmruby rpmrubyGetPool(rpmioPool pool)
Returns the current rpmio pool responsible for Ruby interpreter instances.
static void rpmlog(int code, const char *fmt,...)
Yet Another syslog(3) API clone.
static rpmruby rpmrubyI()
rpmruby rpmrubyNew(char **av, uint32_t flags)
Creates and initializes a Ruby interpreter.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
int _rpmruby_debug
Triggers printing of debugging information.
rpmruby rpmrubyLink(rpmruby ruby)
References a Ruby interpreter instance.
rpmioPool _rpmrubyPool
The pool of Ruby interpreter instances.
Embedded Ruby interpreter.
struct rpmruby_s * rpmruby
enum rpmRC_e rpmRC
RPM return codes.
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
static void rpmrubyFini(void *_ruby)
Finalizes a Ruby interpreter instance/pool item.
rpmRC rpmrubyRun(rpmruby ruby, const char *str, const char **resultp)
Evaluates Ruby code stored in a string.