/* * INIT */ void Init_ossl_digest() { rb_require("openssl"); rb_require("digest"); #if 0 /* let rdoc know about mOSSL */ mOSSL = rb_define_module("OpenSSL"); #endif cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class")); eDigestError = rb_define_class_under(cDigest, "DigestError", eOSSLError); rb_define_alloc_func(cDigest, ossl_digest_alloc); rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1); rb_define_copy_func(cDigest, ossl_digest_copy); rb_define_method(cDigest, "reset", ossl_digest_reset, 0); rb_define_method(cDigest, "update", ossl_digest_update, 1); rb_define_alias(cDigest, "<<", "update"); rb_define_private_method(cDigest, "finish", ossl_digest_finish, -1); rb_define_method(cDigest, "digest_length", ossl_digest_size, 0); rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0); rb_define_method(cDigest, "name", ossl_digest_name, 0); }
void Init_fastxml() { if (xmlHasFeature(XML_WITH_TREE) == 0) rb_raise( rb_eRuntimeError, "libxml not built with tree support" ); if (xmlHasFeature(XML_WITH_XPATH) == 0) rb_raise( rb_eRuntimeError, "libxml not built with xpath support" ); s_readlines = rb_intern("readlines"); s_to_s = rb_intern("to_s"); xmlInitParser(); xmlXPathInit(); xsltInit(); rb_mFastXml = rb_define_module( "FastXml" ); rb_define_const( rb_mFastXml, "LIBXML_VERSION", rb_str_new2( LIBXML_DOTTED_VERSION ) ); /* setting symbols */ rb_sValidateDtd = ID2SYM( rb_intern("validate") ); rb_sForgivingParse = ID2SYM( rb_intern("forgiving") ); rb_sHtmlParse = ID2SYM( rb_intern("html") ); Init_fastxml_doc(); /* Doc */ Init_fastxml_node(); /* Node */ Init_fastxml_nodelist(); /* NodeList */ Init_fastxml_attrlist(); /* AttrList */ /* pull in the ruby side of things */ rb_require( "fastxml/fastxml_lib" ); // ruby-side methods for the FastXml classes rb_require( "fastxml/fastxml_helpers" ); // FastXml and FastHtml methods }
Q_DECL_EXPORT void Init_plasma_applet() { rb_require("korundum4"); // need to initialize the core runtime first init_plasma_Smoke(); set_qtruby_embedded(true); binding = QtRuby::Binding(plasma_Smoke); smokeList << plasma_Smoke; QtRubyModule module = { "Plasma", resolve_classname_plasma, 0, &binding }; qtruby_modules[plasma_Smoke] = module; install_handlers(Plasma_handlers); plasma_module = rb_define_module("Plasma"); plasma_internal_module = rb_define_module_under(plasma_module, "Internal"); rb_define_singleton_method(plasma_module, "method_missing", (VALUE (*) (...)) plasma_module_method_missing, -1); rb_define_singleton_method(plasma_module, "const_missing", (VALUE (*) (...)) plasma_module_method_missing, -1); rb_define_singleton_method(plasma_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0); rb_require("KDE/plasma.rb"); rb_funcall(plasma_internal_module, rb_intern("init_all_classes"), 0); }
void Init_clutter_gst () { rb_require ("glib2"); rb_require ("clutter"); rb_require ("gst"); /* The base class init of some of the clutter-gst classes call some gst functions so unfortunatly defining the Ruby wrappers will crash if clutter_gst_init is not called first */ rbclt_call_init_func (0, NULL, clutter_gst_init); rbcltgst_c_clutter_gst = rb_define_module_under (rbclt_c_clutter, "Gst"); /* Version constants. Not defining a regular VERSION constant because under Ruby-GTK that constant refers to the version of the actual library binary, but there isn't a way to get that with Clutter yet. */ rb_define_const (rbcltgst_c_clutter_gst, "BUILD_VERSION", rb_ary_new3 (3, INT2FIX (CLUTTER_GST_MAJOR_VERSION), INT2FIX (CLUTTER_GST_MINOR_VERSION), INT2FIX (CLUTTER_GST_MICRO_VERSION))); rbcltgst_video_sink_init (); rbcltgst_video_texture_init (); }
void Init_do_sqlite3_ext() { rb_require("bigdecimal"); rb_require("date"); // Get references classes needed for Date/Time parsing rb_cDate = CONST_GET(rb_mKernel, "Date"); rb_cDateTime = CONST_GET(rb_mKernel, "DateTime"); rb_cTime = CONST_GET(rb_mKernel, "Time"); rb_cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal"); rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects")); #ifdef RUBY_LESS_THAN_186 ID_NEW_DATE = rb_intern("new0"); #else ID_NEW_DATE = rb_intern("new!"); #endif ID_RATIONAL = rb_intern("Rational"); ID_LOGGER = rb_intern("logger"); ID_DEBUG = rb_intern("debug"); ID_LEVEL = rb_intern("level"); // Get references to the DataObjects module and its classes mDO = CONST_GET(rb_mKernel, "DataObjects"); cDO_Quoting = CONST_GET(mDO, "Quoting"); cDO_Connection = CONST_GET(mDO, "Connection"); cDO_Command = CONST_GET(mDO, "Command"); cDO_Result = CONST_GET(mDO, "Result"); cDO_Reader = CONST_GET(mDO, "Reader"); // Initialize the DataObjects::Sqlite3 module, and define its classes mSqlite3 = rb_define_module_under(mDO, "Sqlite3"); eSqlite3Error = rb_define_class("Sqlite3Error", rb_eStandardError); cConnection = SQLITE3_CLASS("Connection", cDO_Connection); rb_define_method(cConnection, "initialize", cConnection_initialize, 1); rb_define_method(cConnection, "dispose", cConnection_dispose, 0); cCommand = SQLITE3_CLASS("Command", cDO_Command); rb_include_module(cCommand, cDO_Quoting); rb_define_method(cCommand, "set_types", cCommand_set_types, 1); rb_define_method(cCommand, "execute_non_query", cCommand_execute_non_query, -1); rb_define_method(cCommand, "execute_reader", cCommand_execute_reader, -1); rb_define_method(cCommand, "quote_boolean", cCommand_quote_boolean, 1); rb_define_method(cCommand, "quote_string", cCommand_quote_string, 1); cResult = SQLITE3_CLASS("Result", cDO_Result); cReader = SQLITE3_CLASS("Reader", cDO_Reader); rb_define_method(cReader, "close", cReader_close, 0); rb_define_method(cReader, "next!", cReader_next, 0); rb_define_method(cReader, "values", cReader_values, 0); rb_define_method(cReader, "fields", cReader_fields, 0); rb_define_method(cReader, "field_count", cReader_field_count, 0); rb_define_method(cReader, "row_count", cReader_row_count, 0); }
void Init_wikitext() { // Wikitext mWikitext = rb_define_module("Wikitext"); // Wikitext::Parser cWikitextParser = rb_define_class_under(mWikitext, "Parser", rb_cObject); rb_define_method(cWikitextParser, "initialize", Wikitext_parser_initialize, -1); rb_define_method(cWikitextParser, "parse", Wikitext_parser_parse, -1); rb_define_method(cWikitextParser, "tokenize", Wikitext_parser_tokenize, 1); rb_define_method(cWikitextParser, "benchmarking_tokenize", Wikitext_parser_benchmarking_tokenize, 1); rb_define_method(cWikitextParser, "fulltext_tokenize", Wikitext_parser_fulltext_tokenize, -1); rb_define_singleton_method(cWikitextParser, "sanitize_link_target", Wikitext_parser_sanitize_link_target, 1); rb_define_singleton_method(cWikitextParser, "encode_link_target", Wikitext_parser_encode_link_target, 1); rb_define_attr(cWikitextParser, "line_ending", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "internal_link_prefix", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "img_prefix", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "external_link_class", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "external_link_rel", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "mailto_class", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "link_proc", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "autolink", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "space_to_underscore", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "minimum_fulltext_token_length", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "base_heading_level", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "output_style", Qtrue, Qtrue); // Wikitext::Parser::Error eWikitextParserError = rb_define_class_under(cWikitextParser, "Error", rb_eException); // Wikitext::Parser::Token cWikitextParserToken = rb_define_class_under(cWikitextParser, "Token", rb_cObject); rb_define_singleton_method(cWikitextParserToken, "types", Wikitext_parser_token_types, 0); rb_define_attr(cWikitextParserToken, "start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "line_start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "line_stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "column_start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "column_stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "code_point", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "token_type", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "string_value", Qtrue, Qfalse); // check to see if ::ActiveSupport is defined if (rb_funcall(rb_cObject, rb_intern("const_defined?"), 1, ID2SYM(rb_intern("ActiveSupport"))) == Qtrue) { // we are running under Rails rb_require("wikitext/nil_class"); rb_require("wikitext/string"); VALUE active_support = rb_const_get(rb_cObject, rb_intern("ActiveSupport")); rb_iterate(wikitext_block_forwarder, active_support, wikitext_on_load_block, Qnil); } }
void Init_cbson() { VALUE bson, CBson, Digest, ext_version, digest; static char hostname[MAX_HOSTNAME_LENGTH]; element_assignment_method = rb_intern("[]="); unpack_method = rb_intern("unpack"); utc_method = rb_intern("utc"); lt_operator = rb_intern("<"); gt_operator = rb_intern(">"); bson = rb_const_get(rb_cObject, rb_intern("BSON")); rb_require("bson/types/binary"); Binary = rb_const_get(bson, rb_intern("Binary")); rb_require("bson/types/object_id"); ObjectId = rb_const_get(bson, rb_intern("ObjectId")); rb_require("bson/types/dbref"); DBRef = rb_const_get(bson, rb_intern("DBRef")); rb_require("bson/types/code"); Code = rb_const_get(bson, rb_intern("Code")); rb_require("bson/types/min_max_keys"); MinKey = rb_const_get(bson, rb_intern("MinKey")); MaxKey = rb_const_get(bson, rb_intern("MaxKey")); rb_require("bson/types/timestamp"); Timestamp = rb_const_get(bson, rb_intern("Timestamp")); Regexp = rb_const_get(rb_cObject, rb_intern("Regexp")); rb_require("bson/exceptions"); InvalidKeyName = rb_const_get(bson, rb_intern("InvalidKeyName")); InvalidStringEncoding = rb_const_get(bson, rb_intern("InvalidStringEncoding")); InvalidDocument = rb_const_get(bson, rb_intern("InvalidDocument")); rb_require("bson/ordered_hash"); OrderedHash = rb_const_get(bson, rb_intern("OrderedHash")); RB_HASH = rb_const_get(bson, rb_intern("Hash")); CBson = rb_define_module("CBson"); ext_version = rb_str_new2(VERSION); rb_define_const(CBson, "VERSION", ext_version); rb_define_module_function(CBson, "serialize", method_serialize, 3); rb_define_module_function(CBson, "deserialize", method_deserialize, 1); rb_define_module_function(CBson, "max_bson_size", method_max_bson_size, 0); rb_define_module_function(CBson, "update_max_bson_size", method_update_max_bson_size, 1); rb_require("digest/md5"); Digest = rb_const_get(rb_cObject, rb_intern("Digest")); DigestMD5 = rb_const_get(Digest, rb_intern("MD5")); rb_define_method(ObjectId, "generate", objectid_generate, -1); if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) { rb_raise(rb_eRuntimeError, "failed to get hostname"); } digest = rb_funcall(DigestMD5, rb_intern("digest"), 1, rb_str_new2(hostname)); memcpy(hostname_digest, RSTRING_PTR(digest), 16); hostname_digest[16] = '\0'; max_bson_size = 4 * 1024 * 1024; }
void Init_cbson() { VALUE driver, CBson; Time = rb_const_get(rb_cObject, rb_intern("Time")); driver = rb_const_get(rb_cObject,rb_intern("Mongo")); rb_require("mongo/types/binary"); Binary = rb_const_get(driver, rb_intern("Binary")); rb_require("mongo/types/undefined"); Undefined = rb_const_get(driver, rb_intern("Undefined")); rb_require("mongo/types/objectid"); ObjectID = rb_const_get(driver, rb_intern("ObjectID")); rb_require("mongo/types/dbref"); DBRef = rb_const_get(driver, rb_intern("DBRef")); rb_require("mongo/types/code"); Code = rb_const_get(driver, rb_intern("Code")); rb_require("mongo/types/regexp_of_holding"); RegexpOfHolding = rb_const_get(driver, rb_intern("RegexpOfHolding")); rb_require("mongo/errors"); InvalidName = rb_const_get(driver, rb_intern("InvalidName")); rb_require("mongo/util/ordered_hash"); OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash")); CBson = rb_define_module("CBson"); rb_define_module_function(CBson, "serialize", method_serialize, 2); rb_define_module_function(CBson, "deserialize", method_deserialize, 1); }
void Init_pg_typecast() { rb_require("pg"); rb_require("date"); rb_require("stringio"); rb_require("bigdecimal"); fnew = rb_intern("new"); cStringIO = CONST_GET(rb_mKernel, "StringIO"); cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal"); VALUE cPGresult = rb_define_class("PGresult", rb_cObject); rb_include_module(cPGresult, CONST_GET(rb_mKernel, "Enumerable")); rb_define_method(cPGresult, "each", RUBY_METHOD_FUNC(result_each), 0); }
/** Initializer for the TupleList class */ void Init_rdo_mysql_tuples(void) { rb_require("rdo/mysql"); rb_require("set"); VALUE mMySQL = rb_path2class("RDO::MySQL"); rdo_mysql_cTupleList = rb_define_class_under(mMySQL, "TupleList", rb_cObject); rb_define_method(rdo_mysql_cTupleList, "each", rdo_mysql_tuple_list_each, 0); rb_include_module(rdo_mysql_cTupleList, rb_mEnumerable); }
void Init_cbson() { VALUE mongo, CBson, Digest, ext_version; Time = rb_const_get(rb_cObject, rb_intern("Time")); mongo = rb_const_get(rb_cObject, rb_intern("Mongo")); rb_require("mongo/types/binary"); Binary = rb_const_get(mongo, rb_intern("Binary")); rb_require("mongo/types/objectid"); ObjectID = rb_const_get(mongo, rb_intern("ObjectID")); rb_require("mongo/types/dbref"); DBRef = rb_const_get(mongo, rb_intern("DBRef")); rb_require("mongo/types/code"); Code = rb_const_get(mongo, rb_intern("Code")); rb_require("mongo/types/regexp_of_holding"); RegexpOfHolding = rb_const_get(mongo, rb_intern("RegexpOfHolding")); rb_require("mongo/errors"); InvalidName = rb_const_get(mongo, rb_intern("InvalidName")); InvalidStringEncoding = rb_const_get(mongo, rb_intern("InvalidStringEncoding")); rb_require("mongo/util/ordered_hash"); OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash")); CBson = rb_define_module("CBson"); ext_version = rb_str_new2(VERSION); rb_define_const(CBson, "VERSION", ext_version); rb_define_module_function(CBson, "serialize", method_serialize, 2); rb_define_module_function(CBson, "deserialize", method_deserialize, 1); rb_require("digest/md5"); Digest = rb_const_get(rb_cObject, rb_intern("Digest")); DigestMD5 = rb_const_get(Digest, rb_intern("MD5")); rb_define_method(ObjectID, "generate", objectid_generate, 0); rb_define_method(rb_cArray, "fast_pack", fast_pack, 0); }
void Init_bson_object_id() { VALUE bson; rb_require("bson"); bson = rb_const_get(rb_cObject, rb_intern("BSON")); rb_require("bson/types/object_id"); ObjectId = rb_const_get(bson, rb_intern("ObjectId")); rb_require("bson/exceptions"); InvalidObjectId = rb_const_get(bson, rb_intern("InvalidObjectId")); rb_define_singleton_method(ObjectId, "legal?", objectid_legal, 1); rb_define_singleton_method(ObjectId, "from_string", objectid_from_string, 1); rb_define_method(ObjectId, "to_s", objectid_to_s, 0); }
void init_swift_db_postgres_typecast() { rb_require("bigdecimal"); rb_require("stringio"); rb_require("date"); cStringIO = CONST_GET(rb_mKernel, "StringIO"); cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal"); cDateTime = CONST_GET(rb_mKernel, "DateTime"); fnew = rb_intern("new"); fto_date = rb_intern("to_date"); fstrftime = rb_intern("strftime"); dtformat = rb_str_new2("%F %T.%N %z"); rb_global_variable(&dtformat); }
void Init_trema() { mTrema = rb_define_module( "Trema" ); rb_require( "trema/host" ); rb_require( "trema/path" ); rb_require( "trema/sub-commands" ); rb_require( "trema/switch" ); Init_action_output(); Init_action_set_dl_dst(); Init_action_set_dl_src(); Init_action_enqueue(); Init_action_set_nw_src(); Init_action_set_nw_dst(); Init_action_set_tp_src(); Init_action_set_tp_dst(); Init_action_set_nw_tos(); Init_action_set_vlan_vid(); Init_action_set_vlan_pcp(); Init_action_strip_vlan(); Init_action_vendor(); Init_echo_request(); Init_error(); Init_logger(); Init_controller(); Init_features_reply(); Init_features_request(); Init_set_config(); Init_stats_request(); Init_hello(); Init_match(); Init_packet_in(); Init_port(); Init_flow_removed(); Init_port_status(); Init_stats_reply(); Init_openflow_error(); Init_get_config_request(); Init_get_config_reply(); Init_barrier_request(); Init_barrier_reply(); Init_queue_get_config_request(); Init_queue_get_config_reply(); Init_vendor_request(); Init_port_mod(); rb_require( "trema/exact-match" ); }
Q_DECL_EXPORT void Init_soprano() { init_soprano_Smoke(); binding = QtRuby::Binding(soprano_Smoke); smokeList << soprano_Smoke; QtRubyModule module = { "Soprano", resolve_classname_soprano, 0, &binding }; qtruby_modules[soprano_Smoke] = module; install_handlers(Soprano_handlers); soprano_module = rb_define_module("Soprano"); soprano_internal_module = rb_define_module_under(soprano_module, "Internal"); rb_define_singleton_method(soprano_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0); (void) qRegisterMetaType<Soprano::Statement>(); (void) qRegisterMetaType<Soprano::Node>(); rb_require("soprano/soprano.rb"); rb_funcall(soprano_internal_module, rb_intern("init_all_classes"), 0); }
void Init_xmmsclient_ecore (void) { VALUE m, c; rb_require ("xmmsclient"); rb_require ("ecore"); m = rb_const_get (rb_cModule, rb_intern ("Xmms")); c = rb_const_get (m, rb_intern ("Client")); rb_define_method (c, "add_to_ecore_mainloop", c_add_to_ecore_mainloop, 0); rb_define_method (c, "remove_from_ecore_mainloop", c_remove_from_ecore_mainloop, 0); }
void init_swift_db_mysql_result() { rb_require("bigdecimal"); rb_require("stringio"); rb_require("date"); cDMR = rb_define_class_under(cDMA, "Result", rb_cObject); rb_include_module(cDMR, rb_mEnumerable); rb_define_alloc_func(cDMR, db_mysql_result_allocate); rb_define_method(cDMR, "each", db_mysql_result_each, 0); rb_define_method(cDMR, "selected_rows", db_mysql_result_selected_rows, 0); rb_define_method(cDMR, "affected_rows", db_mysql_result_affected_rows, 0); rb_define_method(cDMR, "fields", db_mysql_result_fields, 0); rb_define_method(cDMR, "types", db_mysql_result_types, 0); rb_define_method(cDMR, "insert_id", db_mysql_result_insert_id, 0); }
void Init_messages( void ) { mMessages = rb_define_module_under( mTrema, "Messages" ); rb_define_module_function( mMessages, "next_xid", next_xid, 0 ); rb_define_module_function( mMessages, "pack_hello_msg", pack_hello_msg, 1 ); rb_define_module_function( mMessages, "pack_echo_request_msg", pack_echo_request_msg, 1 ); rb_define_module_function( mMessages, "pack_features_request_msg", pack_features_request_msg, 1 ); rb_define_module_function( mMessages, "pack_get_config_request_msg", pack_get_config_request_msg, 1 ); rb_define_module_function( mMessages, "pack_set_config_msg", pack_set_config_msg, 1 ); rb_define_module_function( mMessages, "pack_flow_mod_msg", pack_flow_mod_msg, 1 ); rb_define_module_function( mMessages, "pack_group_mod_msg", pack_group_mod_msg, 1 ); rb_define_module_function( mMessages, "pack_flow_multipart_request_msg", pack_flow_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_desc_multipart_request_msg", pack_desc_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_aggregate_multipart_request_msg", pack_aggregate_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_table_multipart_request_msg", pack_table_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_port_multipart_request_msg", pack_port_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_port_desc_multipart_request_msg", pack_port_desc_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_table_features_multipart_request_msg", pack_table_features_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_group_multipart_request_msg", pack_group_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_group_desc_multipart_request_msg", pack_group_desc_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_group_features_multipart_request_msg", pack_group_features_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_queue_multipart_request_msg", pack_queue_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_meter_multipart_request_msg", pack_meter_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_meter_config_multipart_request_msg", pack_meter_config_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_meter_features_multipart_request_msg", pack_meter_features_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_experimenter_multipart_request_msg", pack_experimenter_multipart_request_msg, 1 ); rb_define_module_function( mMessages, "pack_barrier_request_msg", pack_barrier_request_msg, 1 ); rb_require( "trema/messages" ); }
void Init_sv() { rb_require("sv/time"); ServiceError = rb_define_class("ServiceError", rb_eStandardError); ServiceClass = rb_define_class("Service", rb_cObject); rb_define_method(ServiceClass, "control", Service_control, 1); rb_define_method(ServiceClass, "down", Service_down, 0); rb_define_method(ServiceClass, "exit", Service_exit, 0); rb_define_method(ServiceClass, "initialize", Service_initialize, 1); rb_define_method(ServiceClass, "path", Service_get_path, 0); rb_define_method(ServiceClass, "path=", Service_set_path, 1); rb_define_method(ServiceClass, "sigalrm", Service_sigalrm, 0); rb_define_method(ServiceClass, "sigcont", Service_sigcont, 0); rb_define_method(ServiceClass, "sighup", Service_sighup, 0); rb_define_method(ServiceClass, "sigint", Service_sigint, 0); rb_define_method(ServiceClass, "sigkill", Service_sigkill, 0); rb_define_method(ServiceClass, "sigstop", Service_sigstop, 0); rb_define_method(ServiceClass, "sigterm", Service_sigterm, 0); rb_define_method(ServiceClass, "status", Service_get_status, 0); rb_define_method(ServiceClass, "up", Service_up, 0); rb_define_method(ServiceClass, "up_once", Service_up_once, 0); ServiceStatusClass = rb_define_class("ServiceStatus", rb_cObject); rb_define_method(ServiceStatusClass, "mode", ServiceStatus_get_mode, 0); rb_define_method(ServiceStatusClass, "mode=", ServiceStatus_set_mode, 1); rb_define_method(ServiceStatusClass, "paused", ServiceStatus_get_paused, 0); rb_define_method(ServiceStatusClass, "paused=", ServiceStatus_set_paused, 1); rb_define_method(ServiceStatusClass, "pid", ServiceStatus_get_pid, 0); rb_define_method(ServiceStatusClass, "pid=", ServiceStatus_get_pid, 1); rb_define_method(ServiceStatusClass, "timestamp", ServiceStatus_get_timestamp, 0); rb_define_method(ServiceStatusClass, "timestamp=", ServiceStatus_set_timestamp, 0); }
static VALUE load_provider(VALUE arg) { const char *classname = (const char *)arg; VALUE req; /* result of rb_require */ if (classname == NULL || *classname == 0) { _SBLIM_TRACE(1,("Ruby: load_provider(%s) no class given", classname)); return Qfalse; } char *filename = alloca(strlen(classname) * 2 + 1); decamelize(classname, filename); ruby_script(filename); _SBLIM_TRACE(1,("<%d> Ruby: loading (%s)", getpid(), filename)); req = rb_require(filename); /* Qtrue == just loaded, Qfalse = already loaded, else: fail */ if ((req != Qtrue) && (req != Qfalse)) { _SBLIM_TRACE(1,("<%d> require '%s' failed", getpid(), filename)); return Qnil; } /* Get Cmpi::Provider */ VALUE val = rb_const_get(rb_cObject, rb_intern(RB_MODULE_NAME)); if (NIL_P(val)) { _SBLIM_TRACE(1,("<%d> No such module '%s'", getpid(), RB_MODULE_NAME)); return val; } val = rb_const_get(val, rb_intern(classname)); if (NIL_P(val)) { _SBLIM_TRACE(1,("<%d> No such class '%s::%s'", getpid(), RB_MODULE_NAME, classname)); } return val; }
static const rb_transcoder * transcode_dispatch(const char* from_encoding, const char* to_encoding) { char *const key = transcoder_key(from_encoding, to_encoding); st_data_t k, val = 0; while (!st_lookup(transcoder_table, (k = (st_data_t)key), &val) && st_delete(transcoder_lib_table, &k, &val)) { const char *const lib = (const char *)val; int len = strlen(lib); char path[sizeof(transcoder_lib_prefix) + MAX_TRANSCODER_LIBNAME_LEN]; xfree((char *)k); if (len > MAX_TRANSCODER_LIBNAME_LEN) return NULL; memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1); memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len + 1); if (!rb_require(path)) return NULL; } if (!val) { if (!st_lookup(transcoder_table, (st_data_t)key, &val)) { /* multistep logic, via UTF-8 */ if (!encoding_equal(from_encoding, "UTF-8") && !encoding_equal(to_encoding, "UTF-8") && transcode_dispatch("UTF-8", to_encoding)) { /* check that we have a second step */ return transcode_dispatch(from_encoding, "UTF-8"); /* return first step */ } return NULL; } } return (rb_transcoder *)val; }
VALUE require_protect(VALUE arg) { const char *filename = reinterpret_cast<const char*>(arg); rb_require(filename); return Qnil; }
/* * call-seq: * onum.to_r -> rational * * Return the value as a <code>Rational</code>. * */ static VALUE onum_to_r(VALUE self) { VALUE x, y; int nshift = 0; OCINumber onum[2]; int current = 0; boolean is_int; chkerr(OCINumberAssign(oci8_errhp, _NUMBER(self), &onum[0])); for (;;) { chkerr(OCINumberIsInt(oci8_errhp, &onum[current], &is_int)); if (is_int) { break; } nshift++; chkerr(OCINumberShift(oci8_errhp, &onum[current], 1, &onum[1 - current])); current = 1 - current; } x = oci8_make_integer(&onum[current], oci8_errhp); if (nshift == 0) { y = INT2FIX(1); } else { y = rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(nshift)); } #ifdef T_RATIONAL return rb_Rational(x, y); #else if (!cRational) { rb_require("rational"); cRational = rb_const_get(rb_cObject, id_Rational); } return rb_funcall(rb_cObject, id_Rational, 2, x, y); #endif }
void Init_sha2() { VALUE mDigest, cDigest_Base; ID id_metadata; #define DECLARE_ALGO_CLASS(bitlen) \ VALUE cDigest_SHA##bitlen; FOREACH_BITLEN(DECLARE_ALGO_CLASS) rb_require("digest.so"); id_metadata = rb_intern("metadata"); mDigest = rb_path2class("Digest"); cDigest_Base = rb_path2class("Digest::Base"); #define DEFINE_ALGO_CLASS(bitlen) \ cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \ \ rb_cvar_set(cDigest_SHA##bitlen, id_metadata, \ Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen), Qtrue); FOREACH_BITLEN(DEFINE_ALGO_CLASS) }
void Init_stringbuffer(void) { VALUE mDigest, cDigest_Class, cDigest_StringBuffer; /* Digest::Buffer is require that Digest module and Digest::Class class of CRuby built-in */ rb_require("digest"); mDigest = rb_path2class("Digest"); /* class Digest::Buffer < Digest::Class */ cDigest_StringBuffer = rb_define_class_under(mDigest, "StringBuffer", rb_cObject); rb_define_alloc_func(cDigest_StringBuffer, buffer_alloc); rb_define_singleton_method(cDigest_StringBuffer, "digest", buffer_s_digest, -1); rb_define_singleton_method(cDigest_StringBuffer, "hexdigest", buffer_s_hexdigest, -1); rb_define_method(cDigest_StringBuffer, "update", buffer_update, 1); rb_define_alias(cDigest_StringBuffer, "<<", "update"); rb_define_private_method(cDigest_StringBuffer, "finish", buffer_finish, 0); rb_define_method(cDigest_StringBuffer, "reset", buffer_reset, 0); rb_define_method(cDigest_StringBuffer, "digest_length", buffer_digest_length, 0); rb_define_alias(cDigest_StringBuffer, "length", "digest_length"); rb_define_alias(cDigest_StringBuffer, "size", "digest_length"); rb_define_method(cDigest_StringBuffer, "==", buffer_equal, 1); rb_define_method(cDigest_StringBuffer, "initialize_copy", buffer_initialize_copy, 1); rb_define_method(cDigest_StringBuffer, "digest", buffer_digest, -1); rb_define_method(cDigest_StringBuffer, "digest!", buffer_digest_bang, 0); rb_define_method(cDigest_StringBuffer, "hexdigest", buffer_hexdigest, -1); rb_define_method(cDigest_StringBuffer, "hexdigest!", buffer_hexdigest_bang, 0); rb_define_method(cDigest_StringBuffer, "to_s", buffer_to_s, 0); rb_define_method(cDigest_StringBuffer, "buffer", buffer_get, 0); }
static VALUE rb_sigar_set_logger(VALUE obj, VALUE logger) { SIGAR_GET; if (rb_obj_is_kind_of(logger, rb_cProc) || rb_respond_to(logger, rb_intern("call"))) { sigar_log_impl_set(sigar, rbsigar, rb_sigar_proc_impl); rbsigar->logger = logger; return obj; } /* Have to load Logger to test for it properly */ rb_require("logger"); if (rb_obj_is_kind_of(logger, rb_path2class("Logger"))) { sigar_log_impl_set(sigar, rbsigar, rb_sigar_logger_impl); rbsigar->logger = logger; } else { rb_raise(rb_eArgError, "value is not a proc object or subclass of Logger"); } return obj; }
void Init_raindrops_linux_inet_diag(void) { VALUE cRaindrops = rb_const_get(rb_cObject, rb_intern("Raindrops")); VALUE mLinux = rb_define_module_under(cRaindrops, "Linux"); rb_require("socket"); cIDSock = rb_const_get(rb_cObject, rb_intern("Socket")); id_new = rb_intern("new"); /* * Document-class: Raindrops::InetDiagSocket * * This is a subclass of +Socket+ specifically for talking * to the inet_diag facility of Netlink. */ cIDSock = rb_define_class_under(cRaindrops, "InetDiagSocket", cIDSock); rb_define_singleton_method(cIDSock, "new", ids_s_new, 0); cListenStats = rb_const_get(cRaindrops, rb_intern("ListenStats")); rb_define_module_function(mLinux, "tcp_listener_stats", tcp_listener_stats, -1); page_size = getpagesize(); assert(OPLEN <= page_size && "bytecode OPLEN is not <= PAGE_SIZE"); }
static VALUE setup_plruby_oracle(plruby_context_t *ctx) { ub2 id; char name[OCI_NLS_MAXBUFSZ]; VALUE mPLRubyOracle; VALUE enc; chk(OCIAttrGet(ctx->envhp, OCI_HTYPE_ENV, &id, NULL, OCI_ATTR_ENV_CHARSET_ID, ctx->errhp)); OCINlsCharSetIdToName(ctx->envhp, (text*)name, sizeof(name), id); trace(ctx, 1, "before requre 'plruby_oracle'"); rb_require("plruby_oracle"); trace(ctx, 1, "before eval('PLRubyOracle')"); mPLRubyOracle = rb_eval_string("PLRubyOracle"); trace(ctx, 2, "rb_eval_string(\"PLRubyOracle\") => %p", mPLRubyOracle); trace(ctx, 1, "before PLRubyOracle.init('%s')", name); rb_funcall(mPLRubyOracle, rb_intern("init"), 1, rb_usascii_str_new2(name)); enc = rb_cv_get(mPLRubyOracle, "@@encoding"); trace(ctx, 2, "rb_cv_get(mPLRubyOracle, \"@@encoding\") => %s", StringValueCStr(enc)); oracle_encoding = rb_to_encoding(enc); trace(ctx, 2, "rb_enc_get(enc) => %s", rb_enc_name(oracle_encoding)); return Qnil; }
void Init_session_ext() { curl_global_init(CURL_GLOBAL_ALL); rb_require("patron/error"); mPatron = rb_define_module("Patron"); ePatronError = rb_const_get(mPatron, rb_intern("Error")); eUnsupportedProtocol = rb_const_get(mPatron, rb_intern("UnsupportedProtocol")); eURLFormatError = rb_const_get(mPatron, rb_intern("URLFormatError")); eHostResolutionError = rb_const_get(mPatron, rb_intern("HostResolutionError")); eConnectionFailed = rb_const_get(mPatron, rb_intern("ConnectionFailed")); ePartialFileError = rb_const_get(mPatron, rb_intern("PartialFileError")); eTimeoutError = rb_const_get(mPatron, rb_intern("TimeoutError")); eTooManyRedirects = rb_const_get(mPatron, rb_intern("TooManyRedirects")); rb_define_module_function(mPatron, "libcurl_version", libcurl_version, 0); cSession = rb_define_class_under(mPatron, "Session", rb_cObject); cRequest = rb_define_class_under(mPatron, "Request", rb_cObject); rb_define_alloc_func(cSession, session_alloc); rb_define_method(cSession, "ext_initialize", session_ext_initialize, 0); rb_define_method(cSession, "escape", session_escape, 1); rb_define_method(cSession, "unescape", session_unescape, 1); rb_define_method(cSession, "handle_request", session_handle_request, 1); rb_define_method(cSession, "enable_cookie_session", enable_cookie_session, 1); rb_define_const(cRequest, "AuthBasic", INT2FIX(CURLAUTH_BASIC)); rb_define_const(cRequest, "AuthDigest", INT2FIX(CURLAUTH_DIGEST)); rb_define_const(cRequest, "AuthAny", INT2FIX(CURLAUTH_ANY)); }
/* * Document-class: LocalMemCache * * <code>LocalMemCache</code> provides for a Hashtable of strings in shared * memory (via a memory mapped file), which thus can be shared between * processes on a computer. Here is an example of its usage: * * $lm = LocalMemCache.new :namespace => "viewcounters" * $lm[:foo] = 1 * $lm[:foo] # -> "1" * $lm.delete(:foo) * * <code>LocalMemCache</code> can also be used as a persistent key value * database, just use the :filename instead of the :namespace parameter. * * $lm = LocalMemCache.new :filename => "my-database.lmc" * $lm[:foo] = 1 * $lm[:foo] # -> "1" * $lm.delete(:foo) * * == Default sizes of memory pools * * The default size for memory pools is 1024 (MB). It cannot be changed later, * so choose a size that will provide enough space for all your data. You * might consider setting this size to the maximum filesize of your * filesystem. Also note that while these memory pools may look large on your * disk, they really aren't, because with sparse files only those parts of the * file which contain non-null data actually use disk space. * * == Automatic recovery from crashes * * In case a process is terminated while accessing a memory pool, other * processes will wait for the lock up to 2 seconds, and will then try to * resume the aborted operation. This can also be done explicitly by using * LocalMemCache.check(options). * * == Clearing memory pools * * Removing memory pools can be done with LocalMemCache.drop(options). * * == Environment * * If you use the :namespace parameter, the .lmc file for your namespace will * reside in /var/tmp/localmemcache. This can be overriden by setting the * LMC_NAMESPACES_ROOT_PATH variable in the environment. * * == Storing Ruby Objects * * If you want to store Ruby objects instead of just strings, consider * using LocalMemCache::SharedObjectStorage. * */ void Init_rblocalmemcache() { lmc_init(); LocalMemCache = rb_define_class("LocalMemCache", rb_cObject); rb_define_singleton_method(LocalMemCache, "_new", LocalMemCache__new2, 1); rb_define_singleton_method(LocalMemCache, "drop", LocalMemCache__drop, 1); rb_define_singleton_method(LocalMemCache, "check", LocalMemCache__check, 1); rb_define_singleton_method(LocalMemCache, "disable_test_crash", LocalMemCache__disable_test_crash, 0); rb_define_singleton_method(LocalMemCache, "enable_test_crash", LocalMemCache__enable_test_crash, 0); rb_define_method(LocalMemCache, "get", LocalMemCache__get, 1); rb_define_method(LocalMemCache, "[]", LocalMemCache__get, 1); rb_define_method(LocalMemCache, "delete", LocalMemCache__delete, 1); rb_define_method(LocalMemCache, "set", LocalMemCache__set, 2); rb_define_method(LocalMemCache, "clear", LocalMemCache__clear, 0); rb_define_method(LocalMemCache, "[]=", LocalMemCache__set, 2); rb_define_method(LocalMemCache, "keys", LocalMemCache__keys, 0); rb_define_method(LocalMemCache, "each_pair", LocalMemCache__each_pair, 0); rb_define_method(LocalMemCache, "random_pair", LocalMemCache__random_pair, 0); rb_define_method(LocalMemCache, "close", LocalMemCache__close, 0); rb_define_method(LocalMemCache, "size", LocalMemCache__size, 0); rb_define_method(LocalMemCache, "shm_status", LocalMemCache__shm_status, 0); rb_define_method(LocalMemCache, "check_consistency", LocalMemCache__check_consistency, 0); lmc_rb_sym_namespace = ID2SYM(rb_intern("namespace")); lmc_rb_sym_filename = ID2SYM(rb_intern("filename")); lmc_rb_sym_size_mb = ID2SYM(rb_intern("size_mb")); lmc_rb_sym_min_alloc_size = ID2SYM(rb_intern("min_alloc_size")); lmc_rb_sym_force = ID2SYM(rb_intern("force")); rb_require("localmemcache.rb"); }