Ejemplo n.º 1
0
char* proxenet_ruby_plugin(plugin_t* plugin, request_t* request)
{
	char *buf, *plugin_name;
	interpreter_t *interpreter;
	VALUE module, rPlugin;
	ID rFunc;
        int err;

        buf = plugin_name = NULL;
        interpreter = plugin->interpreter;
        module = 0;

        if(isdigit(*plugin->name))
                plugin_name = plugin->name + 1; // this is done to remove the digit of priority
        else
                plugin_name = plugin->name;

        rPlugin = rb_protect( rb_intern_wrap, (VALUE)plugin_name, &err);
        if (err){
                xlog_ruby(LOG_ERROR, "%s(%s) failed miserably\n", "rb_intern", plugin_name);
                proxenet_ruby_print_last_exception();
                return buf;
        }

        module = rb_protect( rb_const_get_wrap, rPlugin, &err);
        if (err){
                xlog_ruby(LOG_ERROR, "%s(%s) failed miserably\n", "rb_const_get", plugin_name);
                proxenet_ruby_print_last_exception();
                return buf;
        }

	switch(request->type){
                case REQUEST:
        		rFunc = (ID) plugin->pre_function;
                        break;
                case RESPONSE:
                        rFunc = (ID) plugin->post_function;
                        break;
                default:
                        abort();
        }

        proxenet_ruby_lock_vm(interpreter);
	buf = proxenet_ruby_execute_function(module, rFunc, request);
	proxenet_ruby_unlock_vm(interpreter);

	return buf;
}
Ejemplo n.º 2
0
char* proxenet_ruby_plugin(plugin_t* plugin, request_t* request)
{
	char* buf = NULL;
	interpreter_t *interpreter = plugin->interpreter;
	ID rFunc;

	if (request->type == REQUEST)
		rFunc = (ID) plugin->pre_function;
	else
		rFunc = (ID) plugin->post_function;

        proxenet_ruby_lock_vm(interpreter);
	buf = proxenet_ruby_execute_function(interpreter, rFunc, request);
	proxenet_ruby_unlock_vm(interpreter);
	return buf;
}