void Init_grpc_call() { /* CallError inherits from Exception to signal that it is non-recoverable */ grpc_rb_eCallError = rb_define_class_under(grpc_rb_mGrpcCore, "CallError", rb_eException); grpc_rb_eOutOfTime = rb_define_class_under(grpc_rb_mGrpcCore, "OutOfTime", rb_eException); grpc_rb_cCall = rb_define_class_under(grpc_rb_mGrpcCore, "Call", rb_cObject); grpc_rb_cMdAry = rb_define_class_under(grpc_rb_mGrpcCore, "MetadataArray", rb_cObject); /* Prevent allocation or inialization of the Call class */ rb_define_alloc_func(grpc_rb_cCall, grpc_rb_cannot_alloc); rb_define_method(grpc_rb_cCall, "initialize", grpc_rb_cannot_init, 0); rb_define_method(grpc_rb_cCall, "initialize_copy", grpc_rb_cannot_init_copy, 1); /* Add ruby analogues of the Call methods. */ rb_define_method(grpc_rb_cCall, "run_batch", grpc_rb_call_run_batch, 4); rb_define_method(grpc_rb_cCall, "cancel", grpc_rb_call_cancel, 0); rb_define_method(grpc_rb_cCall, "peer", grpc_rb_call_get_peer, 0); rb_define_method(grpc_rb_cCall, "peer_cert", grpc_rb_call_get_peer_cert, 0); rb_define_method(grpc_rb_cCall, "status", grpc_rb_call_get_status, 0); rb_define_method(grpc_rb_cCall, "status=", grpc_rb_call_set_status, 1); rb_define_method(grpc_rb_cCall, "metadata", grpc_rb_call_get_metadata, 0); rb_define_method(grpc_rb_cCall, "metadata=", grpc_rb_call_set_metadata, 1); rb_define_method(grpc_rb_cCall, "write_flag", grpc_rb_call_get_write_flag, 0); rb_define_method(grpc_rb_cCall, "write_flag=", grpc_rb_call_set_write_flag, 1); rb_define_method(grpc_rb_cCall, "set_credentials!", grpc_rb_call_set_credentials, 1); /* Ids used to support call attributes */ id_metadata = rb_intern("metadata"); id_status = rb_intern("status"); id_write_flag = rb_intern("write_flag"); /* Ids used by the c wrapping internals. */ id_cq = rb_intern("__cq"); id_flags = rb_intern("__flags"); id_input_md = rb_intern("__input_md"); id_credentials = rb_intern("__credentials"); /* Ids used in constructing the batch result. */ sym_send_message = ID2SYM(rb_intern("send_message")); sym_send_metadata = ID2SYM(rb_intern("send_metadata")); sym_send_close = ID2SYM(rb_intern("send_close")); sym_send_status = ID2SYM(rb_intern("send_status")); sym_message = ID2SYM(rb_intern("message")); sym_status = ID2SYM(rb_intern("status")); sym_cancelled = ID2SYM(rb_intern("cancelled")); /* The Struct used to return the run_batch result. */ grpc_rb_sBatchResult = rb_struct_define( "BatchResult", "send_message", "send_metadata", "send_close", "send_status", "message", "metadata", "status", "cancelled", NULL); /* The hash for reference counting calls, to ensure they can't be destroyed * more than once */ hash_all_calls = rb_hash_new(); rb_define_const(grpc_rb_cCall, "INTERNAL_ALL_CALLs", hash_all_calls); Init_grpc_error_codes(); Init_grpc_op_codes(); Init_grpc_write_flags(); }
/* Foo = NArray::Struct.new { int8 :byte float64 :float, [2,2] dcomplex :compl } */ static VALUE nst_s_new(int argc, VALUE *argv, VALUE klass) { VALUE name=Qnil, rest, size; VALUE st, members; ID id; rb_scan_args(argc, argv, "0*", &rest); if (RARRAY_LEN(rest)>0) { name = RARRAY_PTR(rest)[0]; if (!NIL_P(name)) { VALUE tmp = rb_check_string_type(name); if (!NIL_P(tmp)) { rb_ary_shift(rest); } else { name = Qnil; } } } if (NIL_P(name)) { st = rb_class_new(klass); rb_make_metaclass(st, RBASIC(klass)->klass); rb_class_inherited(klass, st); } else { char *cname = StringValuePtr(name); id = rb_intern(cname); if (!rb_is_const_id(id)) { rb_name_error(id, "identifier %s needs to be constant", cname); } if (rb_const_defined_at(klass, id)) { rb_warn("redefining constant Struct::%s", cname); rb_mod_remove_const(klass, ID2SYM(id)); } st = rb_define_class_under(klass, rb_id2name(id), klass); } rb_iv_set(st, "__members__", rb_ary_new()); rb_iv_set(st, "__offset__", INT2FIX(0)); if (rb_block_given_p()) { rb_mod_module_eval(0, 0, st); } size = rb_iv_get(st, "__offset__"); members = rb_iv_get(st, "__members__"); //printf("size=%d\n",NUM2INT(size)); rb_define_const(st, CONTIGUOUS_STRIDE, size); rb_define_const(st, ELEMENT_BYTE_SIZE, size); rb_define_const(st, ELEMENT_BIT_SIZE, rb_funcall(size,'*',1,INT2FIX(8))); OBJ_FREEZE(members); rb_define_const(st, "DEFINITIONS", members); rb_define_singleton_method(st, "new", rb_class_new_instance, -1); //rb_define_singleton_method(st, "[]", rb_class_new_instance, -1); rb_define_method(st, "allocate", nst_allocate, 0); return st; }
void Init_rugged_diff_delta(void) { rb_cRuggedDiffDelta = rb_define_class_under(rb_cRuggedDiff, "Delta", rb_cObject); }
/* * OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the * OpenSSL[http://www.openssl.org/] library. * * = Examples * * All examples assume you have loaded OpenSSL with: * * require 'openssl' * * These examples build atop each other. For example the key created in the * next is used in throughout these examples. * * == Keys * * === Creating a Key * * This example creates a 2048 bit RSA keypair and writes it to the current * directory. * * key = OpenSSL::PKey::RSA.new 2048 * * open 'private_key.pem', 'w' do |io| io.write key.to_pem end * open 'public_key.pem', 'w' do |io| io.write key.public_key.to_pem end * * === Exporting a Key * * Keys saved to disk without encryption are not secure as anyone who gets * ahold of the key may use it unless it is encrypted. In order to securely * export a key you may export it with a pass phrase. * * cipher = OpenSSL::Cipher.new 'AES-128-CBC' * pass_phrase = 'my secure pass phrase goes here' * * key_secure = key.export cipher, pass_phrase * * open 'private.secure.pem', 'w' do |io| * io.write key_secure * end * * OpenSSL::Cipher.ciphers returns a list of available ciphers. * * === Loading a Key * * A key can also be loaded from a file. * * key2 = OpenSSL::PKey::RSA.new File.read 'private_key.pem' * key2.public? # => true * * or * * key3 = OpenSSL::PKey::RSA.new File.read 'public_key.pem' * key3.private? # => false * * === Loading an Encrypted Key * * OpenSSL will prompt you for your pass phrase when loading an encrypted key. * If you will not be able to type in the pass phrase you may provide it when * loading the key: * * key4_pem = File.read 'private.secure.pem' * key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase * * == RSA Encryption * * RSA provides encryption and decryption using the public and private keys. * You can use a variety of padding methods depending upon the intended use of * encrypted data. * * === Encryption & Decryption * * Asymmetric public/private key encryption is slow and victim to attack in * cases where it is used without padding or directly to encrypt larger chunks * of data. Typical use cases for RSA encryption involve "wrapping" a symmetric * key with the public key of the recipient who would "unwrap" that symmetric * key again using their private key. * The following illustrates a simplified example of such a key transport * scheme. It shouldn't be used in practice, though, standardized protocols * should always be preferred. * * wrapped_key = key.public_encrypt key * * A symmetric key encrypted with the public key can only be decrypted with * the corresponding private key of the recipient. * * original_key = key.private_decrypt wrapped_key * * By default PKCS#1 padding will be used, but it is also possible to use * other forms of padding, see PKey::RSA for further details. * * === Signatures * * Using "private_encrypt" to encrypt some data with the private key is * equivalent to applying a digital signature to the data. A verifying * party may validate the signature by comparing the result of decrypting * the signature with "public_decrypt" to the original data. However, * OpenSSL::PKey already has methods "sign" and "verify" that handle * digital signatures in a standardized way - "private_encrypt" and * "public_decrypt" shouldn't be used in practice. * * To sign a document, a cryptographically secure hash of the document is * computed first, which is then signed using the private key. * * digest = OpenSSL::Digest::SHA256.new * signature = key.sign digest, document * * To validate the signature, again a hash of the document is computed and * the signature is decrypted using the public key. The result is then * compared to the hash just computed, if they are equal the signature was * valid. * * digest = OpenSSL::Digest::SHA256.new * if key.verify digest, signature, document * puts 'Valid' * else * puts 'Invalid' * end * * == PBKDF2 Password-based Encryption * * If supported by the underlying OpenSSL version used, Password-based * Encryption should use the features of PKCS5. If not supported or if * required by legacy applications, the older, less secure methods specified * in RFC 2898 are also supported (see below). * * PKCS5 supports PBKDF2 as it was specified in PKCS#5 * v2.0[http://www.rsa.com/rsalabs/node.asp?id=2127]. It still uses a * password, a salt, and additionally a number of iterations that will * slow the key derivation process down. The slower this is, the more work * it requires being able to brute-force the resulting key. * * === Encryption * * The strategy is to first instantiate a Cipher for encryption, and * then to generate a random IV plus a key derived from the password * using PBKDF2. PKCS #5 v2.0 recommends at least 8 bytes for the salt, * the number of iterations largely depends on the hardware being used. * * cipher = OpenSSL::Cipher.new 'AES-128-CBC' * cipher.encrypt * iv = cipher.random_iv * * pwd = 'some hopefully not to easily guessable password' * salt = OpenSSL::Random.random_bytes 16 * iter = 20000 * key_len = cipher.key_len * digest = OpenSSL::Digest::SHA256.new * * key = OpenSSL::PKCS5.pbkdf2_hmac(pwd, salt, iter, key_len, digest) * cipher.key = key * * Now encrypt the data: * * encrypted = cipher.update document * encrypted << cipher.final * * === Decryption * * Use the same steps as before to derive the symmetric AES key, this time * setting the Cipher up for decryption. * * cipher = OpenSSL::Cipher.new 'AES-128-CBC' * cipher.decrypt * cipher.iv = iv # the one generated with #random_iv * * pwd = 'some hopefully not to easily guessable password' * salt = ... # the one generated above * iter = 20000 * key_len = cipher.key_len * digest = OpenSSL::Digest::SHA256.new * * key = OpenSSL::PKCS5.pbkdf2_hmac(pwd, salt, iter, key_len, digest) * cipher.key = key * * Now decrypt the data: * * decrypted = cipher.update encrypted * decrypted << cipher.final * * == PKCS #5 Password-based Encryption * * PKCS #5 is a password-based encryption standard documented at * RFC2898[http://www.ietf.org/rfc/rfc2898.txt]. It allows a short password or * passphrase to be used to create a secure encryption key. If possible, PBKDF2 * as described above should be used if the circumstances allow it. * * PKCS #5 uses a Cipher, a pass phrase and a salt to generate an encryption * key. * * pass_phrase = 'my secure pass phrase goes here' * salt = '8 octets' * * === Encryption * * First set up the cipher for encryption * * encrypter = OpenSSL::Cipher.new 'AES-128-CBC' * encrypter.encrypt * encrypter.pkcs5_keyivgen pass_phrase, salt * * Then pass the data you want to encrypt through * * encrypted = encrypter.update 'top secret document' * encrypted << encrypter.final * * === Decryption * * Use a new Cipher instance set up for decryption * * decrypter = OpenSSL::Cipher.new 'AES-128-CBC' * decrypter.decrypt * decrypter.pkcs5_keyivgen pass_phrase, salt * * Then pass the data you want to decrypt through * * plain = decrypter.update encrypted * plain << decrypter.final * * == X509 Certificates * * === Creating a Certificate * * This example creates a self-signed certificate using an RSA key and a SHA1 * signature. * * name = OpenSSL::X509::Name.parse 'CN=nobody/DC=example' * * cert = OpenSSL::X509::Certificate.new * cert.version = 2 * cert.serial = 0 * cert.not_before = Time.now * cert.not_after = Time.now + 3600 * * cert.public_key = key.public_key * cert.subject = name * * === Certificate Extensions * * You can add extensions to the certificate with * OpenSSL::SSL::ExtensionFactory to indicate the purpose of the certificate. * * extension_factory = OpenSSL::X509::ExtensionFactory.new nil, cert * * cert.add_extension \ * extension_factory.create_extension('basicConstraints', 'CA:FALSE', true) * * cert.add_extension \ * extension_factory.create_extension( * 'keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature') * * cert.add_extension \ * extension_factory.create_extension('subjectKeyIdentifier', 'hash') * * The list of supported extensions (and in some cases their possible values) * can be derived from the "objects.h" file in the OpenSSL source code. * * === Signing a Certificate * * To sign a certificate set the issuer and use OpenSSL::X509::Certificate#sign * with a digest algorithm. This creates a self-signed cert because we're using * the same name and key to sign the certificate as was used to create the * certificate. * * cert.issuer = name * cert.sign key, OpenSSL::Digest::SHA1.new * * open 'certificate.pem', 'w' do |io| io.write cert.to_pem end * * === Loading a Certificate * * Like a key, a cert can also be loaded from a file. * * cert2 = OpenSSL::X509::Certificate.new File.read 'certificate.pem' * * === Verifying a Certificate * * Certificate#verify will return true when a certificate was signed with the * given public key. * * raise 'certificate can not be verified' unless cert2.verify key * * == Certificate Authority * * A certificate authority (CA) is a trusted third party that allows you to * verify the ownership of unknown certificates. The CA issues key signatures * that indicate it trusts the user of that key. A user encountering the key * can verify the signature by using the CA's public key. * * === CA Key * * CA keys are valuable, so we encrypt and save it to disk and make sure it is * not readable by other users. * * ca_key = OpenSSL::PKey::RSA.new 2048 * * cipher = OpenSSL::Cipher::Cipher.new 'AES-128-CBC' * * open 'ca_key.pem', 'w', 0400 do |io| * io.write key.export(cipher, pass_phrase) * end * * === CA Certificate * * A CA certificate is created the same way we created a certificate above, but * with different extensions. * * ca_name = OpenSSL::X509::Name.parse 'CN=ca/DC=example' * * ca_cert = OpenSSL::X509::Certificate.new * ca_cert.serial = 0 * ca_cert.version = 2 * ca_cert.not_before = Time.now * ca_cert.not_after = Time.now + 86400 * * ca_cert.public_key = ca_key.public_key * ca_cert.subject = ca_name * ca_cert.issuer = ca_name * * extension_factory = OpenSSL::X509::ExtensionFactory.new * extension_factory.subject_certificate = ca_cert * extension_factory.issuer_certificate = ca_cert * * ca_cert.add_extension \ * extension_factory.create_extension('subjectKeyIdentifier', 'hash') * * This extension indicates the CA's key may be used as a CA. * * ca_cert.add_extension \ * extension_factory.create_extension('basicConstraints', 'CA:TRUE', true) * * This extension indicates the CA's key may be used to verify signatures on * both certificates and certificate revocations. * * ca_cert.add_extension \ * extension_factory.create_extension( * 'keyUsage', 'cRLSign,keyCertSign', true) * * Root CA certificates are self-signed. * * ca_cert.sign ca_key, OpenSSL::Digest::SHA1.new * * The CA certificate is saved to disk so it may be distributed to all the * users of the keys this CA will sign. * * open 'ca_cert.pem', 'w' do |io| * io.write ca_cert.to_pem * end * * === Certificate Signing Request * * The CA signs keys through a Certificate Signing Request (CSR). The CSR * contains the information necessary to identify the key. * * csr = OpenSSL::X509::Request.new * csr.version = 0 * csr.subject = name * csr.public_key = key.public_key * csr.sign key, OpenSSL::Digest::SHA1.new * * A CSR is saved to disk and sent to the CA for signing. * * open 'csr.pem', 'w' do |io| * io.write csr.to_pem * end * * === Creating a Certificate from a CSR * * Upon receiving a CSR the CA will verify it before signing it. A minimal * verification would be to check the CSR's signature. * * csr = OpenSSL::X509::Request.new File.read 'csr.pem' * * raise 'CSR can not be verified' unless csr.verify csr.public_key * * After verification a certificate is created, marked for various usages, * signed with the CA key and returned to the requester. * * csr_cert = OpenSSL::X509::Certificate.new * csr_cert.serial = 0 * csr_cert.version = 2 * csr_cert.not_before = Time.now * csr_cert.not_after = Time.now + 600 * * csr_cert.subject = csr.subject * csr_cert.public_key = csr.public_key * csr_cert.issuer = ca_cert.subject * * extension_factory = OpenSSL::X509::ExtensionFactory.new * extension_factory.subject_certificate = csr_cert * extension_factory.issuer_certificate = ca_cert * * csr_cert.add_extension \ * extension_factory.create_extension('basicConstraints', 'CA:FALSE') * * csr_cert.add_extension \ * extension_factory.create_extension( * 'keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature') * * csr_cert.add_extension \ * extension_factory.create_extension('subjectKeyIdentifier', 'hash') * * csr_cert.sign ca_key, OpenSSL::Digest::SHA1.new * * open 'csr_cert.pem', 'w' do |io| * io.write csr_cert.to_pem * end * * == SSL and TLS Connections * * Using our created key and certificate we can create an SSL or TLS connection. * An SSLContext is used to set up an SSL session. * * context = OpenSSL::SSL::SSLContext.new * * === SSL Server * * An SSL server requires the certificate and private key to communicate * securely with its clients: * * context.cert = cert * context.key = key * * Then create an SSLServer with a TCP server socket and the context. Use the * SSLServer like an ordinary TCP server. * * require 'socket' * * tcp_server = TCPServer.new 5000 * ssl_server = OpenSSL::SSL::SSLServer.new tcp_server, context * * loop do * ssl_connection = ssl_server.accept * * data = connection.gets * * response = "I got #{data.dump}" * puts response * * connection.puts "I got #{data.dump}" * connection.close * end * * === SSL client * * An SSL client is created with a TCP socket and the context. * SSLSocket#connect must be called to initiate the SSL handshake and start * encryption. A key and certificate are not required for the client socket. * * require 'socket' * * tcp_client = TCPSocket.new 'localhost', 5000 * ssl_client = OpenSSL::SSL::SSLSocket.new client_socket, context * ssl_client.connect * * ssl_client.puts "hello server!" * puts ssl_client.gets * * === Peer Verification * * An unverified SSL connection does not provide much security. For enhanced * security the client or server can verify the certificate of its peer. * * The client can be modified to verify the server's certificate against the * certificate authority's certificate: * * context.ca_file = 'ca_cert.pem' * context.verify_mode = OpenSSL::SSL::VERIFY_PEER * * require 'socket' * * tcp_client = TCPSocket.new 'localhost', 5000 * ssl_client = OpenSSL::SSL::SSLSocket.new client_socket, context * ssl_client.connect * * ssl_client.puts "hello server!" * puts ssl_client.gets * * If the server certificate is invalid or <tt>context.ca_file</tt> is not set * when verifying peers an OpenSSL::SSL::SSLError will be raised. * */ void Init_openssl() { /* * Init timezone info */ #if 0 tzset(); #endif /* * Init all digests, ciphers */ /* CRYPTO_malloc_init(); */ /* ENGINE_load_builtin_engines(); */ OpenSSL_add_ssl_algorithms(); OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); SSL_load_error_strings(); /* * FIXME: * On unload do: */ #if 0 CONF_modules_unload(1); destroy_ui_method(); EVP_cleanup(); ENGINE_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); ERR_free_strings(); #endif /* * Init main module */ mOSSL = rb_define_module("OpenSSL"); /* * OpenSSL ruby extension version */ rb_define_const(mOSSL, "VERSION", rb_str_new2(OSSL_VERSION)); /* * Version of OpenSSL the ruby OpenSSL extension was built with */ rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT)); /* * Version number of OpenSSL the ruby OpenSSL extension was built with * (base 16) */ rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER)); /* * Boolean indicating whether OpenSSL is FIPS-enabled or not */ #ifdef HAVE_OPENSSL_FIPS rb_define_const(mOSSL, "OPENSSL_FIPS", Qtrue); #else rb_define_const(mOSSL, "OPENSSL_FIPS", Qfalse); #endif rb_define_module_function(mOSSL, "fips_mode=", ossl_fips_mode_set, 1); /* * Generic error, * common for all classes under OpenSSL module */ eOSSLError = rb_define_class_under(mOSSL,"OpenSSLError",rb_eStandardError); /* * Verify callback Proc index for ext-data */ if ((ossl_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, (void *)"ossl_verify_cb_idx", 0, 0, 0)) < 0) ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index"); /* * Init debug core */ dOSSL = Qfalse; rb_define_module_function(mOSSL, "debug", ossl_debug_get, 0); rb_define_module_function(mOSSL, "debug=", ossl_debug_set, 1); rb_define_module_function(mOSSL, "errors", ossl_get_errors, 0); /* * Get ID of to_der */ ossl_s_to_der = rb_intern("to_der"); /* * Init components */ Init_ossl_bn(); Init_ossl_cipher(); Init_ossl_config(); Init_ossl_digest(); Init_ossl_hmac(); Init_ossl_ns_spki(); Init_ossl_pkcs12(); Init_ossl_pkcs7(); Init_ossl_pkcs5(); Init_ossl_pkey(); Init_ossl_rand(); Init_ossl_ssl(); Init_ossl_x509(); Init_ossl_ocsp(); Init_ossl_engine(); Init_ossl_asn1(); }
void Init_oci8_lob(VALUE cOCI8) { id_plus = rb_intern("+"); id_dir_alias = rb_intern("@dir_alias"); id_filename = rb_intern("@filename"); seek_set = rb_eval_string("::IO::SEEK_SET"); seek_cur = rb_eval_string("::IO::SEEK_CUR"); seek_end = rb_eval_string("::IO::SEEK_END"); #if 0 /* for yard */ cOCIHandle = rb_define_class("OCIHandle", rb_cObject); cOCI8 = rb_define_class("OCI8", cOCIHandle); cOCI8LOB = rb_define_class_under(cOCI8, "LOB", cOCIHandle); cOCI8CLOB = rb_define_class_under(cOCI8, "CLOB", cOCI8LOB); cOCI8NCLOB = rb_define_class_under(cOCI8, "NCLOB", cOCI8LOB); cOCI8BLOB = rb_define_class_under(cOCI8, "BLOB", cOCI8LOB); cOCI8BFILE = rb_define_class_under(cOCI8, "BFILE", cOCI8LOB); #endif cOCI8LOB = oci8_define_class_under(cOCI8, "LOB", &oci8_lob_data_type, oci8_lob_alloc); cOCI8CLOB = oci8_define_class_under(cOCI8, "CLOB", &oci8_clob_data_type, oci8_clob_alloc); cOCI8NCLOB = oci8_define_class_under(cOCI8, "NCLOB", &oci8_nclob_data_type, oci8_nclob_alloc); cOCI8BLOB = oci8_define_class_under(cOCI8, "BLOB", &oci8_blob_data_type, oci8_blob_alloc); cOCI8BFILE = oci8_define_class_under(cOCI8, "BFILE", &oci8_bfile_data_type, oci8_bfile_alloc); rb_define_method(cOCI8CLOB, "initialize", oci8_clob_initialize, -1); rb_define_method(cOCI8NCLOB, "initialize", oci8_nclob_initialize, -1); rb_define_method(cOCI8BLOB, "initialize", oci8_blob_initialize, -1); rb_define_method(cOCI8LOB, "available?", oci8_lob_available_p, 0); rb_define_method(cOCI8LOB, "size", oci8_lob_get_size, 0); rb_define_method(cOCI8LOB, "pos", oci8_lob_get_pos, 0); rb_define_alias(cOCI8LOB, "tell", "pos"); rb_define_method(cOCI8LOB, "eof?", oci8_lob_eof_p, 0); rb_define_method(cOCI8LOB, "seek", oci8_lob_seek, -1); rb_define_method(cOCI8LOB, "rewind", oci8_lob_rewind, 0); rb_define_method(cOCI8LOB, "truncate", oci8_lob_truncate, 1); rb_define_method(cOCI8LOB, "size=", oci8_lob_set_size, 1); rb_define_method(cOCI8LOB, "read", oci8_lob_read, -1); rb_define_method(cOCI8LOB, "write", oci8_lob_write, 1); rb_define_method(cOCI8LOB, "close", oci8_lob_close, 0); rb_define_method(cOCI8LOB, "sync", oci8_lob_get_sync, 0); rb_define_method(cOCI8LOB, "sync=", oci8_lob_set_sync, 1); rb_define_method(cOCI8LOB, "flush", oci8_lob_flush, 0); rb_define_method(cOCI8LOB, "chunk_size", oci8_lob_get_chunk_size, 0); rb_define_method(cOCI8BFILE, "initialize", oci8_bfile_initialize, -1); rb_define_method(cOCI8BFILE, "dir_alias", oci8_bfile_get_dir_alias, 0); rb_define_method(cOCI8BFILE, "filename", oci8_bfile_get_filename, 0); rb_define_method(cOCI8BFILE, "dir_alias=", oci8_bfile_set_dir_alias, 1); rb_define_method(cOCI8BFILE, "filename=", oci8_bfile_set_filename, 1); rb_define_method(cOCI8BFILE, "exists?", oci8_bfile_exists_p, 0); rb_define_method(cOCI8BFILE, "truncate", oci8_bfile_error, 1); rb_define_method(cOCI8BFILE, "size=", oci8_bfile_error, 1); rb_define_method(cOCI8BFILE, "write", oci8_bfile_error, 1); oci8_define_bind_class("CLOB", &bind_clob_data_type.bind, bind_clob_alloc); oci8_define_bind_class("NCLOB", &bind_nclob_data_type.bind, bind_nclob_alloc); oci8_define_bind_class("BLOB", &bind_blob_data_type.bind, bind_blob_alloc); oci8_define_bind_class("BFILE", &bind_bfile_data_type.bind, bind_bfile_alloc); }
void Init_cairo_context (void) { cr_id_surface = rb_intern ("surface"); cr_id_source = rb_intern ("source"); cr_id_plus = rb_intern ("+"); cr_id_minus = rb_intern ("-"); cr_id_multi = rb_intern ("*"); cr_id_div = rb_intern ("/"); rb_cCairo_Context = rb_define_class_under (rb_mCairo, "Context", rb_cObject); rb_define_alloc_func (rb_cCairo_Context, cr_allocate); rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context); rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil); /* Functions for manipulating state objects */ rb_define_method (rb_cCairo_Context, "initialize", cr_initialize, 1); rb_define_method (rb_cCairo_Context, "destroy", cr_destroy, 0); rb_define_method (rb_cCairo_Context, "save", cr_save, 0); rb_define_method (rb_cCairo_Context, "restore", cr_restore, 0); rb_define_method (rb_cCairo_Context, "push_group", cr_push_group, -1); rb_define_method (rb_cCairo_Context, "pop_group", cr_pop_group_generic, -1); rb_define_method (rb_cCairo_Context, "pop_group_to_source", cr_pop_group_to_source, 0); /* Modify state */ rb_define_method (rb_cCairo_Context, "set_operator", cr_set_operator, 1); rb_define_method (rb_cCairo_Context, "set_source", cr_set_source_generic, -1); rb_define_method (rb_cCairo_Context, "set_source_rgb", cr_set_source_rgb, -1); rb_define_method (rb_cCairo_Context, "set_source_rgba", cr_set_source_rgba, -1); rb_define_method (rb_cCairo_Context, "set_tolerance", cr_set_tolerance, 1); rb_define_method (rb_cCairo_Context, "set_antialias", cr_set_antialias, 1); rb_define_method (rb_cCairo_Context, "set_fill_rule", cr_set_fill_rule, 1); rb_define_method (rb_cCairo_Context, "set_line_width", cr_set_line_width, 1); rb_define_method (rb_cCairo_Context, "set_line_cap", cr_set_line_cap, 1); rb_define_method (rb_cCairo_Context, "set_line_join", cr_set_line_join, 1); rb_define_method (rb_cCairo_Context, "set_dash", cr_set_dash, -1); rb_define_method (rb_cCairo_Context, "set_miter_limit", cr_set_miter_limit, 1); rb_define_method (rb_cCairo_Context, "translate", cr_translate, 2); rb_define_method (rb_cCairo_Context, "scale", cr_scale, 2); rb_define_method (rb_cCairo_Context, "rotate", cr_rotate, 1); rb_define_method (rb_cCairo_Context, "transform", cr_transform, 1); rb_define_method (rb_cCairo_Context, "set_matrix", cr_set_matrix, 1); rb_define_method (rb_cCairo_Context, "identity_matrix", cr_identity_matrix, 0); rb_define_method (rb_cCairo_Context, "user_to_device", cr_user_to_device, 2); rb_define_method (rb_cCairo_Context, "user_to_device_distance", cr_user_to_device_distance, 2); rb_define_method (rb_cCairo_Context, "device_to_user", cr_device_to_user, 2); rb_define_method (rb_cCairo_Context, "device_to_user_distance", cr_device_to_user_distance, 2); /* Path creation functions */ rb_define_method (rb_cCairo_Context, "new_path", cr_new_path, 0); rb_define_method (rb_cCairo_Context, "move_to", cr_move_to, 2); rb_define_method (rb_cCairo_Context, "new_sub_path", cr_new_sub_path, 0); rb_define_method (rb_cCairo_Context, "line_to", cr_line_to, 2); rb_define_method (rb_cCairo_Context, "curve_to", cr_curve_to_generic, -1); rb_define_method (rb_cCairo_Context, "arc", cr_arc, 5); rb_define_method (rb_cCairo_Context, "arc_negative", cr_arc_negative, 5); rb_define_method (rb_cCairo_Context, "rel_move_to", cr_rel_move_to, 2); rb_define_method (rb_cCairo_Context, "rel_line_to", cr_rel_line_to, 2); rb_define_method (rb_cCairo_Context, "rel_curve_to", cr_rel_curve_to_generic, -1); rb_define_method (rb_cCairo_Context, "rectangle", cr_rectangle, 4); rb_define_method (rb_cCairo_Context, "close_path", cr_close_path, 0); #if CAIRO_CHECK_VERSION(1, 5, 8) rb_define_method (rb_cCairo_Context, "path_extents", cr_path_extents, 0); #endif /* Painting functions */ rb_define_method (rb_cCairo_Context, "paint", cr_paint_generic, -1); rb_define_method (rb_cCairo_Context, "mask", cr_mask_generic, -1); rb_define_method (rb_cCairo_Context, "stroke", cr_stroke, -1); rb_define_method (rb_cCairo_Context, "fill", cr_fill, -1); rb_define_method (rb_cCairo_Context, "copy_page", cr_copy_page, 0); rb_define_method (rb_cCairo_Context, "show_page", cr_show_page, 0); /* Insideness testing */ rb_define_method (rb_cCairo_Context, "in_stroke?", cr_in_stroke, 2); rb_define_method (rb_cCairo_Context, "in_fill?", cr_in_fill, 2); #if CAIRO_CHECK_VERSION(1, 10, 0) rb_define_method (rb_cCairo_Context, "in_clip?", cr_in_clip, 2); #endif /* Rectangular extents */ rb_define_method (rb_cCairo_Context, "stroke_extents", cr_stroke_extents, 0); rb_define_method (rb_cCairo_Context, "fill_extents", cr_fill_extents, 0); /* Clipping */ rb_define_method (rb_cCairo_Context, "reset_clip", cr_reset_clip, 0); rb_define_method (rb_cCairo_Context, "clip", cr_clip, -1); #if CAIRO_CHECK_VERSION(1, 3, 0) rb_define_method (rb_cCairo_Context, "clip_extents", cr_clip_extents, 0); rb_define_method (rb_cCairo_Context, "clip_rectangle_list", cr_clip_rectangle_list, 0); #endif /* Font/Text functions */ rb_define_method (rb_cCairo_Context, "select_font_face", cr_select_font_face, -1); rb_define_method (rb_cCairo_Context, "set_font_size", cr_set_font_size, 1); rb_define_method (rb_cCairo_Context, "set_font_matrix", cr_set_font_matrix, 1); rb_define_method (rb_cCairo_Context, "font_matrix", cr_get_font_matrix, 0); rb_define_method (rb_cCairo_Context, "set_font_options", cr_set_font_options, 1); rb_define_method (rb_cCairo_Context, "font_options", cr_get_font_options, 0); rb_define_method (rb_cCairo_Context, "set_font_face", cr_set_font_face, 1); rb_define_method (rb_cCairo_Context, "font_face", cr_get_font_face, 0); rb_define_method (rb_cCairo_Context, "set_scaled_font", cr_set_scaled_font, 1); #if CAIRO_CHECK_VERSION(1, 3, 16) rb_define_method (rb_cCairo_Context, "scaled_font", cr_get_scaled_font, 0); #endif rb_define_method (rb_cCairo_Context, "show_text", cr_show_text, 1); rb_define_method (rb_cCairo_Context, "show_glyphs", cr_show_glyphs, 1); #if CAIRO_CHECK_VERSION(1, 8, 0) rb_define_method (rb_cCairo_Context, "show_text_glyphs", cr_show_text_glyphs, 4); #endif rb_define_method (rb_cCairo_Context, "text_path", cr_text_path, 1); rb_define_method (rb_cCairo_Context, "glyph_path", cr_glyph_path, 1); rb_define_method (rb_cCairo_Context, "text_extents", cr_text_extents, 1); rb_define_method (rb_cCairo_Context, "glyph_extents", cr_glyph_extents, 1); rb_define_method (rb_cCairo_Context, "font_extents", cr_font_extents, 0); /* Query functions */ rb_define_method (rb_cCairo_Context, "operator", cr_get_operator, 0); rb_define_method (rb_cCairo_Context, "source", cr_get_source, 0); rb_define_method (rb_cCairo_Context, "tolerance", cr_get_tolerance, 0); rb_define_method (rb_cCairo_Context, "antialias", cr_get_antialias, 0); #if CAIRO_CHECK_VERSION(1, 5, 10) rb_define_method (rb_cCairo_Context, "have_current_point?", cr_has_current_point, 0); rb_define_alias (rb_cCairo_Context, "has_current_point?", "have_current_point?"); #endif rb_define_method (rb_cCairo_Context, "current_point", cr_get_current_point, 0); rb_define_method (rb_cCairo_Context, "fill_rule", cr_get_fill_rule, 0); rb_define_method (rb_cCairo_Context, "line_width", cr_get_line_width, 0); rb_define_method (rb_cCairo_Context, "line_cap", cr_get_line_cap, 0); rb_define_method (rb_cCairo_Context, "line_join", cr_get_line_join, 0); rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0); #if CAIRO_CHECK_VERSION(1, 3, 0) rb_define_method (rb_cCairo_Context, "dash_count", cr_get_dash_count, 0); rb_define_method (rb_cCairo_Context, "dash", cr_get_dash, 0); #endif rb_define_method (rb_cCairo_Context, "matrix", cr_get_matrix, 0); rb_define_method (rb_cCairo_Context, "target", cr_get_target, 0); rb_define_method (rb_cCairo_Context, "group_target", cr_get_group_target, 0); /* Paths */ rb_define_method (rb_cCairo_Context, "copy_path", cr_copy_path, 0); rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0); rb_define_method (rb_cCairo_Context, "append_path", cr_copy_append_path, 1); RB_CAIRO_DEF_SETTERS (rb_cCairo_Context); }
void Init_dl(void) { void Init_dlhandle(void); void Init_dlcfunc(void); void Init_dlptr(void); rbdl_id_cdecl = rb_intern_const("cdecl"); rbdl_id_stdcall = rb_intern_const("stdcall"); /* Document-module: DL * * A bridge to the dlopen() or dynamic library linker function. * * == Example * * bash $> cat > sum.c <<EOF * double sum(double *arry, int len) * { * double ret = 0; * int i; * for(i = 0; i < len; i++){ * ret = ret + arry[i]; * } * return ret; * } * * double split(double num) * { * double ret = 0; * ret = num / 2; * return ret; * } * EOF * bash $> gcc -o libsum.so -shared sum.c * bash $> cat > sum.rb <<EOF * require 'dl' * require 'dl/import' * * module LibSum * extend DL::Importer * dlload './libsum.so' * extern 'double sum(double*, int)' * extern 'double split(double)' * end * * a = [2.0, 3.0, 4.0] * * sum = LibSum.sum(a.pack("d*"), a.count) * p LibSum.split(sum) * EOF * bash $> ruby sum.rb * 4.5 * * WIN! :-) */ rb_mDL = rb_define_module("DL"); /* * Document-class: DL::DLError * * standard dynamic load exception */ rb_eDLError = rb_define_class_under(rb_mDL, "DLError", rb_eStandardError); /* * Document-class: DL::DLTypeError * * dynamic load incorrect type exception */ rb_eDLTypeError = rb_define_class_under(rb_mDL, "DLTypeError", rb_eDLError); /* Document-const: MAX_CALLBACK * * Maximum number of callbacks */ rb_define_const(rb_mDL, "MAX_CALLBACK", INT2NUM(MAX_CALLBACK)); /* Document-const: DLSTACK_SIZE * * Dynamic linker stack size */ rb_define_const(rb_mDL, "DLSTACK_SIZE", INT2NUM(DLSTACK_SIZE)); rb_dl_init_callbacks(rb_mDL); /* Document-const: RTLD_GLOBAL * * rtld DL::Handle flag. * * The symbols defined by this library will be made available for symbol * resolution of subsequently loaded libraries. */ rb_define_const(rb_mDL, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL)); /* Document-const: RTLD_LAZY * * rtld DL::Handle flag. * * Perform lazy binding. Only resolve symbols as the code that references * them is executed. If the symbol is never referenced, then it is never * resolved. (Lazy binding is only performed for function references; * references to variables are always immediately bound when the library * is loaded.) */ rb_define_const(rb_mDL, "RTLD_LAZY", INT2NUM(RTLD_LAZY)); /* Document-const: RTLD_NOW * * rtld DL::Handle flag. * * If this value is specified or the environment variable LD_BIND_NOW is * set to a nonempty string, all undefined symbols in the library are * resolved before dlopen() returns. If this cannot be done an error is * returned. */ rb_define_const(rb_mDL, "RTLD_NOW", INT2NUM(RTLD_NOW)); /* Document-const: TYPE_VOID * * DL::CFunc type - void */ rb_define_const(rb_mDL, "TYPE_VOID", INT2NUM(DLTYPE_VOID)); /* Document-const: TYPE_VOIDP * * DL::CFunc type - void* */ rb_define_const(rb_mDL, "TYPE_VOIDP", INT2NUM(DLTYPE_VOIDP)); /* Document-const: TYPE_CHAR * * DL::CFunc type - char */ rb_define_const(rb_mDL, "TYPE_CHAR", INT2NUM(DLTYPE_CHAR)); /* Document-const: TYPE_SHORT * * DL::CFunc type - short */ rb_define_const(rb_mDL, "TYPE_SHORT", INT2NUM(DLTYPE_SHORT)); /* Document-const: TYPE_INT * * DL::CFunc type - int */ rb_define_const(rb_mDL, "TYPE_INT", INT2NUM(DLTYPE_INT)); /* Document-const: TYPE_LONG * * DL::CFunc type - long */ rb_define_const(rb_mDL, "TYPE_LONG", INT2NUM(DLTYPE_LONG)); #if HAVE_LONG_LONG /* Document-const: TYPE_LONG_LONG * * DL::CFunc type - long long */ rb_define_const(rb_mDL, "TYPE_LONG_LONG", INT2NUM(DLTYPE_LONG_LONG)); #endif /* Document-const: TYPE_FLOAT * * DL::CFunc type - float */ rb_define_const(rb_mDL, "TYPE_FLOAT", INT2NUM(DLTYPE_FLOAT)); /* Document-const: TYPE_DOUBLE * * DL::CFunc type - double */ rb_define_const(rb_mDL, "TYPE_DOUBLE", INT2NUM(DLTYPE_DOUBLE)); /* Document-const: ALIGN_VOIDP * * The Offset of a struct void* and a void* */ rb_define_const(rb_mDL, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP)); /* Document-const: ALIGN_CHAR * * The Offset of a struct char and a char */ rb_define_const(rb_mDL, "ALIGN_CHAR", INT2NUM(ALIGN_CHAR)); /* Document-const: ALIGN_SHORT * * The Offset of a struct short and a short */ rb_define_const(rb_mDL, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT)); /* Document-const: ALIGN_INT * * The Offset of a struct int and a int */ rb_define_const(rb_mDL, "ALIGN_INT", INT2NUM(ALIGN_INT)); /* Document-const: ALIGN_LONG * * The Offset of a struct long and a long */ rb_define_const(rb_mDL, "ALIGN_LONG", INT2NUM(ALIGN_LONG)); #if HAVE_LONG_LONG /* Document-const: ALIGN_LONG_LONG * * The Offset of a struct long long and a long long */ rb_define_const(rb_mDL, "ALIGN_LONG_LONG", INT2NUM(ALIGN_LONG_LONG)); #endif /* Document-const: ALIGN_FLOAT * * The Offset of a struct float and a float */ rb_define_const(rb_mDL, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT)); /* Document-const: ALIGN_DOUBLE * * The Offset of a struct double and a double */ rb_define_const(rb_mDL, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE)); /* Document-const: SIZEOF_VOIDP * * OS Dependent - sizeof(void*) */ rb_define_const(rb_mDL, "SIZEOF_VOIDP", INT2NUM(sizeof(void*))); /* Document-const: SIZEOF_CHAR * * OS Dependent - sizeof(char) */ rb_define_const(rb_mDL, "SIZEOF_CHAR", INT2NUM(sizeof(char))); /* Document-const: SIZEOF_SHORT * * OS Dependent - sizeof(short) */ rb_define_const(rb_mDL, "SIZEOF_SHORT", INT2NUM(sizeof(short))); /* Document-const: SIZEOF_INT * * OS Dependent - sizeof(int) */ rb_define_const(rb_mDL, "SIZEOF_INT", INT2NUM(sizeof(int))); /* Document-const: SIZEOF_LONG * * OS Dependent - sizeof(long) */ rb_define_const(rb_mDL, "SIZEOF_LONG", INT2NUM(sizeof(long))); #if HAVE_LONG_LONG /* Document-const: SIZEOF_LONG_LONG * * OS Dependent - sizeof(long long) */ rb_define_const(rb_mDL, "SIZEOF_LONG_LONG", INT2NUM(sizeof(LONG_LONG))); #endif /* Document-const: SIZEOF_FLOAT * * OS Dependent - sizeof(float) */ rb_define_const(rb_mDL, "SIZEOF_FLOAT", INT2NUM(sizeof(float))); /* Document-const: SIZEOF_DOUBLE * * OS Dependent - sizeof(double) */ rb_define_const(rb_mDL, "SIZEOF_DOUBLE",INT2NUM(sizeof(double))); rb_define_module_function(rb_mDL, "dlwrap", rb_dl_value2ptr, 1); rb_define_module_function(rb_mDL, "dlunwrap", rb_dl_ptr2value, 1); rb_define_module_function(rb_mDL, "dlopen", rb_dl_dlopen, -1); rb_define_module_function(rb_mDL, "malloc", rb_dl_malloc, 1); rb_define_module_function(rb_mDL, "realloc", rb_dl_realloc, 2); rb_define_module_function(rb_mDL, "free", rb_dl_free, 1); /* Document-const: RUBY_FREE * * Address of the ruby_xfree() function */ rb_define_const(rb_mDL, "RUBY_FREE", PTR2NUM(ruby_xfree)); /* Document-const: BUILD_RUBY_PLATFORM * * Platform built against (i.e. "x86_64-linux", etc.) * * See also RUBY_PLATFORM */ rb_define_const(rb_mDL, "BUILD_RUBY_PLATFORM", rb_str_new2(RUBY_PLATFORM)); /* Document-const: BUILD_RUBY_VERSION * * Ruby Version built. (i.e. "1.9.3") * * See also RUBY_VERSION */ rb_define_const(rb_mDL, "BUILD_RUBY_VERSION", rb_str_new2(RUBY_VERSION)); Init_dlhandle(); Init_dlcfunc(); Init_dlptr(); }
void Init_rsvg2(void) { VALUE mRSVG = rb_define_module("RSVG"); #if LIBRSVG_CHECK_VERSION(2, 9, 0) rsvg_init(); atexit(rsvg_term); #endif #ifdef RSVG_TYPE_HANDLE cHandle = G_DEF_CLASS(RSVG_TYPE_HANDLE, "Handle", mRSVG); #else cHandle = rb_define_class_under(mRSVG, "Handle", rb_cObject); rb_define_alloc_func(cHandle, rb_rsvg_handle_alloc); #endif G_DEF_ERROR(RSVG_ERROR, "Error", mRSVG, rb_eRuntimeError, RSVG_TYPE_ERROR); id_call = rb_intern("call"); id_callback = rb_intern("callback"); id_closed = rb_intern("closed"); id_to_s = rb_intern("to_s"); rb_define_const(mRSVG, "BINDING_VERSION", rb_ary_new3(3, INT2FIX(RBRSVG_MAJOR_VERSION), INT2FIX(RBRSVG_MINOR_VERSION), INT2FIX(RBRSVG_MICRO_VERSION))); rb_define_const(mRSVG, "BUILD_VERSION", rb_ary_new3(3, INT2FIX(LIBRSVG_MAJOR_VERSION), INT2FIX(LIBRSVG_MINOR_VERSION), INT2FIX(LIBRSVG_MICRO_VERSION))); rb_define_module_function(mRSVG, "set_default_dpi", rb_rsvg_set_default_dpi, 1); rb_define_module_function(mRSVG, "set_default_dpi_x_y", rb_rsvg_set_default_dpi_x_y, 2); #ifdef HAVE_TYPE_RSVGDIMENSIONDATA cDim = rb_define_class_under(mRSVG, "DimensionData", rb_cObject); rb_define_alloc_func(cDim, rb_rsvg_dim_alloc); rb_define_method(cDim, "initialize", rb_rsvg_dim_initialize, -1); rb_define_method(cDim, "width", rb_rsvg_dim_get_width, 0); rb_define_method(cDim, "set_width", rb_rsvg_dim_set_width, 1); rb_define_method(cDim, "height", rb_rsvg_dim_get_height, 0); rb_define_method(cDim, "set_height", rb_rsvg_dim_set_height, 1); rb_define_method(cDim, "em", rb_rsvg_dim_get_em, 0); rb_define_method(cDim, "set_em", rb_rsvg_dim_set_em, 1); rb_define_method(cDim, "ex", rb_rsvg_dim_get_ex, 0); rb_define_method(cDim, "set_ex", rb_rsvg_dim_set_ex, 1); rb_define_method(cDim, "to_s", rb_rsvg_dim_to_s, 0); rb_define_method(cDim, "to_a", rb_rsvg_dim_to_a, 0); rb_define_alias(cDim, "to_ary", "to_a"); G_DEF_SETTERS(cDim); #endif #if LIBRSVG_CHECK_VERSION(2, 14, 0) rb_define_module_function(cHandle, "new_from_data", rb_rsvg_handle_new_from_data, 1); rb_define_module_function(cHandle, "new_from_file", rb_rsvg_handle_new_from_file, 1); #endif rb_define_method(cHandle, "initialize", rb_rsvg_handle_initialize, -1); rb_define_method(cHandle, "set_size_callback", rb_rsvg_handle_set_size_callback, 0); rb_define_method(cHandle, "set_dpi", rb_rsvg_handle_set_dpi, 1); rb_define_method(cHandle, "set_dpi_x_y", rb_rsvg_handle_set_dpi_x_y, 2); rb_define_method(cHandle, "write", rb_rsvg_handle_write, 1); rb_define_method(cHandle, "close", rb_rsvg_handle_close, 0); rb_define_method(cHandle, "closed?", rb_rsvg_handle_closed, 0); rb_define_method(cHandle, "pixbuf", rb_rsvg_handle_get_pixbuf, -1); #if LIBRSVG_CHECK_VERSION(2, 9, 0) rb_define_method(cHandle, "base_uri", rb_rsvg_handle_get_base_uri, 0); rb_define_method(cHandle, "set_base_uri", rb_rsvg_handle_set_base_uri, 1); #endif /* Convenience API */ rb_define_module_function(mRSVG, "pixbuf_from_file", rb_rsvg_pixbuf_from_file, 1); rb_define_module_function(mRSVG, "pixbuf_from_file_at_zoom", rb_rsvg_pixbuf_from_file_at_zoom, 3); rb_define_module_function(mRSVG, "pixbuf_from_file_at_size", rb_rsvg_pixbuf_from_file_at_size, 3); rb_define_module_function(mRSVG, "pixbuf_from_file_at_max_size", rb_rsvg_pixbuf_from_file_at_max_size, 3); rb_define_module_function(mRSVG, "pixbuf_from_file_at_zoom_with_max", rb_rsvg_pixbuf_from_file_at_zoom_with_max, 5); #ifdef HAVE_TYPE_RSVGDIMENSIONDATA rb_define_method(cHandle, "dimensions", rb_rsvg_handle_get_dim, 0); #endif /* Accessibility API */ rb_define_method(cHandle, "title", rb_rsvg_handle_get_title, 0); rb_define_method(cHandle, "desc", rb_rsvg_handle_get_desc, 0); #ifdef HAVE_RSVG_HANDLE_GET_METADATA rb_define_method(cHandle, "metadata", rb_rsvg_handle_get_metadata, 0); #endif #if !LIBRSVG_CHECK_VERSION(2, 11, 0) /* Extended Convenience API */ rb_define_method(cHandle, "pixbuf_from_file_at_size", rb_rsvg_pixbuf_from_file_at_size_ex, 3); rb_define_method(cHandle, "pixbuf_from_file", rb_rsvg_pixbuf_from_file_ex, 1); rb_define_method(cHandle, "pixbuf_from_file_at_zoom", rb_rsvg_pixbuf_from_file_at_zoom_ex, 3); rb_define_method(cHandle, "pixbuf_from_file_at_max_size", rb_rsvg_pixbuf_from_file_at_max_size_ex, 3); rb_define_method(cHandle, "pixbuf_from_file_at_zoom_with_max", rb_rsvg_pixbuf_from_file_at_zoom_with_max_ex, 5); #endif rb_define_singleton_method(mRSVG, "cairo_available?", rb_rsvg_cairo_available, 0); #ifdef HAVE_LIBRSVG_RSVG_CAIRO_H rb_define_method(cHandle, "render_cairo", rb_rsvg_handle_render_cairo, -1); #endif G_DEF_SETTERS(cHandle); }
void Init_gsl_odeiv(VALUE module) { VALUE mgsl_odeiv; mgsl_odeiv = rb_define_module_under(module, "Odeiv"); rb_define_const(mgsl_odeiv, "HADJ_DEC", INT2FIX(GSL_ODEIV_HADJ_DEC)); rb_define_const(mgsl_odeiv, "HADJ_INC", INT2FIX(GSL_ODEIV_HADJ_INC)); rb_define_const(mgsl_odeiv, "HADJ_NIL", INT2FIX(GSL_ODEIV_HADJ_NIL)); cgsl_odeiv_step = rb_define_class_under(mgsl_odeiv, "Step", cGSL_Object); rb_define_singleton_method(cgsl_odeiv_step, "alloc", rb_gsl_odeiv_step_new, -1); /*****/ rb_define_const(cgsl_odeiv_step, "RK2", INT2FIX(GSL_ODEIV_STEP_RK2)); rb_define_const(cgsl_odeiv_step, "RK4", INT2FIX(GSL_ODEIV_STEP_RK4)); rb_define_const(cgsl_odeiv_step, "RKF45", INT2FIX(GSL_ODEIV_STEP_RKF45)); rb_define_const(cgsl_odeiv_step, "RKCK", INT2FIX(GSL_ODEIV_STEP_RKCK)); rb_define_const(cgsl_odeiv_step, "RK8PD", INT2FIX(GSL_ODEIV_STEP_RK8PD)); rb_define_const(cgsl_odeiv_step, "RK2IMP", INT2FIX(GSL_ODEIV_STEP_RK2IMP)); rb_define_const(cgsl_odeiv_step, "RK4IMP", INT2FIX(GSL_ODEIV_STEP_RK4IMP)); rb_define_const(cgsl_odeiv_step, "BSIMP", INT2FIX(GSL_ODEIV_STEP_BSIMP)); rb_define_const(cgsl_odeiv_step, "GEAR1", INT2FIX(GSL_ODEIV_STEP_GEAR1)); rb_define_const(cgsl_odeiv_step, "GEAR2", INT2FIX(GSL_ODEIV_STEP_GEAR2)); rb_define_const(cgsl_odeiv_step, "RK2SIMP", INT2FIX(GSL_ODEIV_STEP_RK2SIMP)); /*****/ rb_define_method(cgsl_odeiv_step, "reset", rb_gsl_odeiv_step_reset, 0); rb_define_method(cgsl_odeiv_step, "name", rb_gsl_odeiv_step_name, 0); rb_define_method(cgsl_odeiv_step, "order", rb_gsl_odeiv_step_order, 0); rb_define_method(cgsl_odeiv_step, "dimension", rb_gsl_odeiv_step_dimension, 0); rb_define_alias(cgsl_odeiv_step, "dim", "dimension"); rb_define_method(cgsl_odeiv_step, "apply", rb_gsl_odeiv_step_apply, -1); rb_define_method(cgsl_odeiv_step, "info", rb_gsl_odeiv_step_info, 0); /****/ cgsl_odeiv_control = rb_define_class_under(mgsl_odeiv, "Control", cGSL_Object); rb_define_singleton_method(cgsl_odeiv_control, "alloc", rb_gsl_odeiv_control_standard_new, 4); rb_define_singleton_method(cgsl_odeiv_control, "standard_alloc", rb_gsl_odeiv_control_standard_new, 4); rb_define_singleton_method(cgsl_odeiv_control, "y_new", rb_gsl_odeiv_control_y_new, 2); rb_define_singleton_method(cgsl_odeiv_control, "yp_new", rb_gsl_odeiv_control_yp_new, 2); rb_define_singleton_method(cgsl_odeiv_control, "scaled_alloc", rb_gsl_odeiv_control_scaled_new, 5); rb_define_method(cgsl_odeiv_control, "init", rb_gsl_odeiv_control_init, 4); rb_define_method(cgsl_odeiv_control, "name", rb_gsl_odeiv_control_name, 0); rb_define_method(cgsl_odeiv_control, "hadjust", rb_gsl_odeiv_control_hadjust, 5); /****/ cgsl_odeiv_evolve = rb_define_class_under(mgsl_odeiv, "Evolve", cGSL_Object); rb_define_singleton_method(cgsl_odeiv_evolve, "alloc", rb_gsl_odeiv_evolve_new, 1); rb_define_method(cgsl_odeiv_evolve, "reset", rb_gsl_odeiv_evolve_reset, 0); rb_define_method(cgsl_odeiv_evolve, "apply", rb_gsl_odeiv_evolve_apply, 7); rb_define_method(cgsl_odeiv_evolve, "count", rb_gsl_odeiv_evolve_count, 0); rb_define_method(cgsl_odeiv_evolve, "dimension", rb_gsl_odeiv_evolve_dimension, 0); rb_define_method(cgsl_odeiv_evolve, "failed_steps", rb_gsl_odeiv_evolve_failed_steps, 0); rb_define_method(cgsl_odeiv_evolve, "last_step", rb_gsl_odeiv_evolve_last_step, 0); rb_define_method(cgsl_odeiv_evolve, "y0", rb_gsl_odeiv_evolve_y0, 0); rb_define_method(cgsl_odeiv_evolve, "yerr", rb_gsl_odeiv_evolve_yerr, 0); /*****/ cgsl_odeiv_system = rb_define_class_under(mgsl_odeiv, "System", cGSL_Object); rb_define_singleton_method(cgsl_odeiv_system, "alloc", rb_gsl_odeiv_system_new, -1); rb_define_method(cgsl_odeiv_system, "set", rb_gsl_odeiv_system_set, -1); rb_define_method(cgsl_odeiv_system, "set_params", rb_gsl_odeiv_system_set_params, -1); rb_define_method(cgsl_odeiv_system, "params", rb_gsl_odeiv_system_params, 0); rb_define_method(cgsl_odeiv_system, "function", rb_gsl_odeiv_system_function, 0); rb_define_alias(cgsl_odeiv_system, "func", "function"); rb_define_method(cgsl_odeiv_system, "jacobian", rb_gsl_odeiv_system_jacobian, 0); rb_define_alias(cgsl_odeiv_system, "jac", "jacobian"); rb_define_method(cgsl_odeiv_system, "dimension", rb_gsl_odeiv_system_dimension, 0); rb_define_alias(cgsl_odeiv_system, "dim", "dimension"); /*****/ cgsl_odeiv_solver = rb_define_class_under(mgsl_odeiv, "Solver", cGSL_Object); rb_define_singleton_method(cgsl_odeiv_solver, "alloc", rb_gsl_odeiv_solver_new, -1); rb_define_method(cgsl_odeiv_solver, "step", rb_gsl_odeiv_solver_step, 0); rb_define_method(cgsl_odeiv_solver, "control", rb_gsl_odeiv_solver_control, 0); rb_define_method(cgsl_odeiv_solver, "evolve", rb_gsl_odeiv_solver_evolve, 0); rb_define_method(cgsl_odeiv_solver, "sys", rb_gsl_odeiv_solver_sys, 0); rb_define_method(cgsl_odeiv_solver, "apply", rb_gsl_odeiv_solver_apply, 4); rb_define_method(cgsl_odeiv_solver, "set_evolve", rb_gsl_odeiv_solver_set_evolve, 1); rb_define_method(cgsl_odeiv_solver, "set_step", rb_gsl_odeiv_solver_set_step, 1); rb_define_method(cgsl_odeiv_solver, "set_control", rb_gsl_odeiv_solver_set_control, 1); rb_define_method(cgsl_odeiv_solver, "set_system", rb_gsl_odeiv_solver_set_sys, 1); rb_define_method(cgsl_odeiv_solver, "reset", rb_gsl_odeiv_solver_reset, 0); rb_define_method(cgsl_odeiv_solver, "dim", rb_gsl_odeiv_solver_dim, 0); rb_define_alias(cgsl_odeiv_solver, "dimension", "dim"); rb_define_method(cgsl_odeiv_solver, "set_params", rb_gsl_odeiv_solver_set_params, -1); rb_define_method(cgsl_odeiv_solver, "params", rb_gsl_odeiv_solver_params, 0); }
void Init_generator() { rb_require("json/common"); mJSON = rb_define_module("JSON"); mExt = rb_define_module_under(mJSON, "Ext"); mGenerator = rb_define_module_under(mExt, "Generator"); eGeneratorError = rb_path2class("JSON::GeneratorError"); eNestingError = rb_path2class("JSON::NestingError"); cState = rb_define_class_under(mGenerator, "State", rb_cObject); rb_define_alloc_func(cState, cState_s_allocate); rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1); rb_define_method(cState, "initialize", cState_initialize, -1); rb_define_method(cState, "initialize_copy", cState_init_copy, 1); rb_define_method(cState, "indent", cState_indent, 0); rb_define_method(cState, "indent=", cState_indent_set, 1); rb_define_method(cState, "space", cState_space, 0); rb_define_method(cState, "space=", cState_space_set, 1); rb_define_method(cState, "space_before", cState_space_before, 0); rb_define_method(cState, "space_before=", cState_space_before_set, 1); rb_define_method(cState, "object_nl", cState_object_nl, 0); rb_define_method(cState, "object_nl=", cState_object_nl_set, 1); rb_define_method(cState, "array_nl", cState_array_nl, 0); rb_define_method(cState, "array_nl=", cState_array_nl_set, 1); rb_define_method(cState, "max_nesting", cState_max_nesting, 0); rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1); rb_define_method(cState, "check_circular?", cState_check_circular_p, 0); rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0); rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0); rb_define_method(cState, "quirks_mode?", cState_quirks_mode_p, 0); rb_define_method(cState, "quirks_mode", cState_quirks_mode_p, 0); rb_define_method(cState, "quirks_mode=", cState_quirks_mode_set, 1); rb_define_method(cState, "depth", cState_depth, 0); rb_define_method(cState, "depth=", cState_depth_set, 1); rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0); rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1); rb_define_method(cState, "configure", cState_configure, 1); rb_define_alias(cState, "merge", "configure"); rb_define_method(cState, "to_h", cState_to_h, 0); rb_define_method(cState, "[]", cState_aref, 1); rb_define_method(cState, "generate", cState_generate, 1); mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods"); mObject = rb_define_module_under(mGeneratorMethods, "Object"); rb_define_method(mObject, "to_json", mObject_to_json, -1); mHash = rb_define_module_under(mGeneratorMethods, "Hash"); rb_define_method(mHash, "to_json", mHash_to_json, -1); mArray = rb_define_module_under(mGeneratorMethods, "Array"); rb_define_method(mArray, "to_json", mArray_to_json, -1); mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum"); rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1); mBignum = rb_define_module_under(mGeneratorMethods, "Bignum"); rb_define_method(mBignum, "to_json", mBignum_to_json, -1); mFloat = rb_define_module_under(mGeneratorMethods, "Float"); rb_define_method(mFloat, "to_json", mFloat_to_json, -1); mString = rb_define_module_under(mGeneratorMethods, "String"); rb_define_singleton_method(mString, "included", mString_included_s, 1); rb_define_method(mString, "to_json", mString_to_json, -1); rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1); rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0); mString_Extend = rb_define_module_under(mString, "Extend"); rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1); mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass"); rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1); mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass"); rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1); mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass"); rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1); CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE")); i_to_s = rb_intern("to_s"); i_to_json = rb_intern("to_json"); i_new = rb_intern("new"); i_indent = rb_intern("indent"); i_space = rb_intern("space"); i_space_before = rb_intern("space_before"); i_object_nl = rb_intern("object_nl"); i_array_nl = rb_intern("array_nl"); i_max_nesting = rb_intern("max_nesting"); i_allow_nan = rb_intern("allow_nan"); i_ascii_only = rb_intern("ascii_only"); i_quirks_mode = rb_intern("quirks_mode"); i_depth = rb_intern("depth"); i_buffer_initial_length = rb_intern("buffer_initial_length"); i_pack = rb_intern("pack"); i_unpack = rb_intern("unpack"); i_create_id = rb_intern("create_id"); i_extend = rb_intern("extend"); i_key_p = rb_intern("key?"); i_aref = rb_intern("[]"); i_send = rb_intern("__send__"); i_respond_to_p = rb_intern("respond_to?"); i_match = rb_intern("match"); i_keys = rb_intern("keys"); i_dup = rb_intern("dup"); #ifdef HAVE_RUBY_ENCODING_H CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); i_encoding = rb_intern("encoding"); i_encode = rb_intern("encode"); #endif i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE"); CJSON_SAFE_STATE_PROTOTYPE = Qnil; }
void Init_generator() { rb_require("json/common"); mJSON = rb_define_module("JSON"); mExt = rb_define_module_under(mJSON, "Ext"); mGenerator = rb_define_module_under(mExt, "Generator"); eGeneratorError = rb_path2class("JSON::GeneratorError"); eCircularDatastructure = rb_path2class("JSON::CircularDatastructure"); eNestingError = rb_path2class("JSON::NestingError"); cState = rb_define_class_under(mGenerator, "State", rb_cObject); rb_define_alloc_func(cState, cState_s_allocate); rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1); rb_define_method(cState, "initialize", cState_initialize, -1); rb_define_method(cState, "indent", cState_indent, 0); rb_define_method(cState, "indent=", cState_indent_set, 1); rb_define_method(cState, "space", cState_space, 0); rb_define_method(cState, "space=", cState_space_set, 1); rb_define_method(cState, "space_before", cState_space_before, 0); rb_define_method(cState, "space_before=", cState_space_before_set, 1); rb_define_method(cState, "object_nl", cState_object_nl, 0); rb_define_method(cState, "object_nl=", cState_object_nl_set, 1); rb_define_method(cState, "array_nl", cState_array_nl, 0); rb_define_method(cState, "array_nl=", cState_array_nl_set, 1); rb_define_method(cState, "check_circular?", cState_check_circular_p, 0); rb_define_method(cState, "max_nesting", cState_max_nesting, 0); rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1); rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0); rb_define_method(cState, "seen?", cState_seen_p, 1); rb_define_method(cState, "remember", cState_remember, 1); rb_define_method(cState, "forget", cState_forget, 1); rb_define_method(cState, "configure", cState_configure, 1); rb_define_method(cState, "to_h", cState_to_h, 0); mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods"); mObject = rb_define_module_under(mGeneratorMethods, "Object"); rb_define_method(mObject, "to_json", mObject_to_json, -1); mHash = rb_define_module_under(mGeneratorMethods, "Hash"); rb_define_method(mHash, "to_json", mHash_to_json, -1); mArray = rb_define_module_under(mGeneratorMethods, "Array"); rb_define_method(mArray, "to_json", mArray_to_json, -1); mInteger = rb_define_module_under(mGeneratorMethods, "Integer"); rb_define_method(mInteger, "to_json", mInteger_to_json, -1); mFloat = rb_define_module_under(mGeneratorMethods, "Float"); rb_define_method(mFloat, "to_json", mFloat_to_json, -1); mString = rb_define_module_under(mGeneratorMethods, "String"); rb_define_singleton_method(mString, "included", mString_included_s, 1); rb_define_method(mString, "to_json", mString_to_json, -1); rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1); rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0); mString_Extend = rb_define_module_under(mString, "Extend"); rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1); mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass"); rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1); mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass"); rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1); mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass"); rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1); i_to_s = rb_intern("to_s"); i_to_json = rb_intern("to_json"); i_new = rb_intern("new"); i_indent = rb_intern("indent"); i_space = rb_intern("space"); i_space_before = rb_intern("space_before"); i_object_nl = rb_intern("object_nl"); i_array_nl = rb_intern("array_nl"); i_check_circular = rb_intern("check_circular"); i_max_nesting = rb_intern("max_nesting"); i_allow_nan = rb_intern("allow_nan"); i_pack = rb_intern("pack"); i_unpack = rb_intern("unpack"); i_create_id = rb_intern("create_id"); i_extend = rb_intern("extend"); }
void Init_hamming_window() { VALUE m_noyes_c = rb_define_module("NoyesC"); cHammingWindow = rb_define_class_under(m_noyes_c, "HammingWindow", rb_cObject); rb_define_method(cHammingWindow, "initialize", t_init, -2); rb_define_method(cHammingWindow, "<<", t_left_shift, 1); }
/* * = Ruby bindings for kerberos * * The module Krb5Auth provides bindings to kerberos version 5 libraries */ void Init_krb5_auth() { mKerberos = rb_define_module("Krb5Auth"); cKrb5 = rb_define_class_under(mKerberos,"Krb5", rb_cObject); cKrb5_Exception = rb_define_class_under(cKrb5, "Exception", rb_eStandardError); cCred = rb_define_class_under(cKrb5, "Cred", rb_cObject); rb_define_attr(cCred, "client", 1, 0); rb_define_attr(cCred, "server", 1, 0); rb_define_attr(cCred, "starttime", 1, 0); rb_define_attr(cCred, "authtime", 1, 0); rb_define_attr(cCred, "endtime", 1, 0); rb_define_attr(cCred, "ticket_flags", 1, 0); rb_define_attr(cCred, "cred_enctype", 1, 0); rb_define_attr(cCred, "ticket_enctype", 1, 0); #define DEF_FLAG_CONST(name) \ rb_define_const(cCred, #name, INT2NUM(name)) DEF_FLAG_CONST(TKT_FLG_FORWARDABLE); DEF_FLAG_CONST(TKT_FLG_FORWARDED); DEF_FLAG_CONST(TKT_FLG_PROXIABLE); DEF_FLAG_CONST(TKT_FLG_PROXY); DEF_FLAG_CONST(TKT_FLG_MAY_POSTDATE); DEF_FLAG_CONST(TKT_FLG_POSTDATED); DEF_FLAG_CONST(TKT_FLG_INVALID); DEF_FLAG_CONST(TKT_FLG_RENEWABLE); DEF_FLAG_CONST(TKT_FLG_INITIAL); DEF_FLAG_CONST(TKT_FLG_HW_AUTH); DEF_FLAG_CONST(TKT_FLG_PRE_AUTH); DEF_FLAG_CONST(TKT_FLG_TRANSIT_POLICY_CHECKED); DEF_FLAG_CONST(TKT_FLG_OK_AS_DELEGATE); DEF_FLAG_CONST(TKT_FLG_ANONYMOUS); #undef DEF_FLAG_CONST #define DEF_ENC_CONST(name) \ rb_define_const(cCred, #name, INT2NUM(name)) DEF_ENC_CONST(ENCTYPE_NULL); DEF_ENC_CONST(ENCTYPE_DES_CBC_CRC); DEF_ENC_CONST(ENCTYPE_DES_CBC_MD4); DEF_ENC_CONST(ENCTYPE_DES_CBC_MD5); DEF_ENC_CONST(ENCTYPE_DES_CBC_RAW); DEF_ENC_CONST(ENCTYPE_DES3_CBC_SHA); DEF_ENC_CONST(ENCTYPE_DES3_CBC_RAW); DEF_ENC_CONST(ENCTYPE_DES_HMAC_SHA1); DEF_ENC_CONST(ENCTYPE_DES3_CBC_SHA1); DEF_ENC_CONST(ENCTYPE_AES128_CTS_HMAC_SHA1_96); DEF_ENC_CONST(ENCTYPE_AES256_CTS_HMAC_SHA1_96); DEF_ENC_CONST(ENCTYPE_ARCFOUR_HMAC); DEF_ENC_CONST(ENCTYPE_ARCFOUR_HMAC_EXP); DEF_ENC_CONST(ENCTYPE_UNKNOWN); #undef DEF_ENC_CONST rb_define_singleton_method(cKrb5, "new", Krb5_new, 0); rb_define_method(cKrb5, "get_init_creds_password", Krb5_get_init_creds_password, 2); rb_define_method(cKrb5, "get_init_creds_keytab", Krb5_get_init_creds_keytab, -1); rb_define_method(cKrb5, "get_default_realm", Krb5_get_default_realm, 0); rb_define_method(cKrb5, "get_default_principal", Krb5_get_default_principal, 0); rb_define_method(cKrb5, "change_password", Krb5_change_password, 2); rb_define_method(cKrb5, "set_password", Krb5_set_password, 1); rb_define_method(cKrb5, "cache", Krb5_cache_creds, -1); rb_define_method(cKrb5, "list_cache", Krb5_list_cache_creds, -1); rb_define_method(cKrb5, "destroy", Krb5_destroy_creds, -1); rb_define_method(cKrb5, "close", Krb5_close, 0); /* 0.8.0: The version of the krb5-auth library */ rb_define_const(cKrb5, "VERSION", rb_str_new2("0.8.0")); }
void init_mysql2_client() { cMysql2Client = rb_define_class_under(mMysql2, "Client", rb_cObject); rb_define_alloc_func(cMysql2Client, allocate); rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0); rb_define_method(cMysql2Client, "query", rb_mysql_client_query, -1); rb_define_method(cMysql2Client, "escape", rb_mysql_client_escape, 1); rb_define_method(cMysql2Client, "info", rb_mysql_client_info, 0); rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 0); rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0); rb_define_method(cMysql2Client, "async_result", rb_mysql_client_async_result, 0); rb_define_method(cMysql2Client, "last_id", rb_mysql_client_last_id, 0); rb_define_method(cMysql2Client, "affected_rows", rb_mysql_client_affected_rows, 0); rb_define_private_method(cMysql2Client, "reconnect=", set_reconnect, 1); rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1); rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1); rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); rb_define_private_method(cMysql2Client, "init_connection", init_connection, 0); rb_define_private_method(cMysql2Client, "connect", rb_connect, 7); intern_encoding_from_charset = rb_intern("encoding_from_charset"); sym_id = ID2SYM(rb_intern("id")); sym_version = ID2SYM(rb_intern("version")); sym_async = ID2SYM(rb_intern("async")); sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); sym_as = ID2SYM(rb_intern("as")); sym_array = ID2SYM(rb_intern("array")); intern_merge = rb_intern("merge"); intern_error_number_eql = rb_intern("error_number="); intern_sql_state_eql = rb_intern("sql_state="); #ifdef CLIENT_LONG_PASSWORD rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"), INT2NUM(CLIENT_LONG_PASSWORD)); #endif #ifdef CLIENT_FOUND_ROWS rb_const_set(cMysql2Client, rb_intern("FOUND_ROWS"), INT2NUM(CLIENT_FOUND_ROWS)); #endif #ifdef CLIENT_LONG_FLAG rb_const_set(cMysql2Client, rb_intern("LONG_FLAG"), INT2NUM(CLIENT_LONG_FLAG)); #endif #ifdef CLIENT_CONNECT_WITH_DB rb_const_set(cMysql2Client, rb_intern("CONNECT_WITH_DB"), INT2NUM(CLIENT_CONNECT_WITH_DB)); #endif #ifdef CLIENT_NO_SCHEMA rb_const_set(cMysql2Client, rb_intern("NO_SCHEMA"), INT2NUM(CLIENT_NO_SCHEMA)); #endif #ifdef CLIENT_COMPRESS rb_const_set(cMysql2Client, rb_intern("COMPRESS"), INT2NUM(CLIENT_COMPRESS)); #endif #ifdef CLIENT_ODBC rb_const_set(cMysql2Client, rb_intern("ODBC"), INT2NUM(CLIENT_ODBC)); #endif #ifdef CLIENT_LOCAL_FILES rb_const_set(cMysql2Client, rb_intern("LOCAL_FILES"), INT2NUM(CLIENT_LOCAL_FILES)); #endif #ifdef CLIENT_IGNORE_SPACE rb_const_set(cMysql2Client, rb_intern("IGNORE_SPACE"), INT2NUM(CLIENT_IGNORE_SPACE)); #endif #ifdef CLIENT_PROTOCOL_41 rb_const_set(cMysql2Client, rb_intern("PROTOCOL_41"), INT2NUM(CLIENT_PROTOCOL_41)); #endif #ifdef CLIENT_INTERACTIVE rb_const_set(cMysql2Client, rb_intern("INTERACTIVE"), INT2NUM(CLIENT_INTERACTIVE)); #endif #ifdef CLIENT_SSL rb_const_set(cMysql2Client, rb_intern("SSL"), INT2NUM(CLIENT_SSL)); #endif #ifdef CLIENT_IGNORE_SIGPIPE rb_const_set(cMysql2Client, rb_intern("IGNORE_SIGPIPE"), INT2NUM(CLIENT_IGNORE_SIGPIPE)); #endif #ifdef CLIENT_TRANSACTIONS rb_const_set(cMysql2Client, rb_intern("TRANSACTIONS"), INT2NUM(CLIENT_TRANSACTIONS)); #endif #ifdef CLIENT_RESERVED rb_const_set(cMysql2Client, rb_intern("RESERVED"), INT2NUM(CLIENT_RESERVED)); #endif #ifdef CLIENT_SECURE_CONNECTION rb_const_set(cMysql2Client, rb_intern("SECURE_CONNECTION"), INT2NUM(CLIENT_SECURE_CONNECTION)); #endif #ifdef CLIENT_MULTI_STATEMENTS rb_const_set(cMysql2Client, rb_intern("MULTI_STATEMENTS"), INT2NUM(CLIENT_MULTI_STATEMENTS)); #endif #ifdef CLIENT_PS_MULTI_RESULTS rb_const_set(cMysql2Client, rb_intern("PS_MULTI_RESULTS"), INT2NUM(CLIENT_PS_MULTI_RESULTS)); #endif #ifdef CLIENT_SSL_VERIFY_SERVER_CERT rb_const_set(cMysql2Client, rb_intern("SSL_VERIFY_SERVER_CERT"), INT2NUM(CLIENT_SSL_VERIFY_SERVER_CERT)); #endif #ifdef CLIENT_REMEMBER_OPTIONS rb_const_set(cMysql2Client, rb_intern("REMEMBER_OPTIONS"), INT2NUM(CLIENT_REMEMBER_OPTIONS)); #endif #ifdef CLIENT_ALL_FLAGS rb_const_set(cMysql2Client, rb_intern("ALL_FLAGS"), INT2NUM(CLIENT_ALL_FLAGS)); #endif #ifdef CLIENT_BASIC_FLAGS rb_const_set(cMysql2Client, rb_intern("BASIC_FLAGS"), INT2NUM(CLIENT_BASIC_FLAGS)); #endif }
void Init_poppler_action(VALUE mPoppler) { VALUE cDest, cAction, cActionAny, cActionGotoDest, cActionGotoRemote; VALUE cActionLaunch, cActionUri, cActionNamed, cActionMovie; cAction = G_DEF_CLASS(POPPLER_TYPE_ACTION, "Action", mPoppler); cActionAny = rb_define_class_under(mPoppler, "ActionAny", cAction); rb_define_method(cActionAny, "type", action_any_type, 0); DEFINE_ACTION_ACCESSOR(cActionAny, any, title); cActionGotoDest = rb_define_class_under(mPoppler, "ActionGotoDest", cActionAny); DEFINE_ACTION_ACCESSOR(cActionGotoDest, goto_dest, dest); cActionGotoRemote = rb_define_class_under(mPoppler, "ActionGotoRemote", cActionAny); DEFINE_ACTION_ACCESSOR(cActionGotoRemote, goto_remote, file_name); DEFINE_ACTION_ACCESSOR(cActionGotoRemote, goto_remote, dest); cActionLaunch = rb_define_class_under(mPoppler, "ActionLaunch", cActionAny); DEFINE_ACTION_ACCESSOR(cActionLaunch, launch, file_name); DEFINE_ACTION_ACCESSOR(cActionLaunch, launch, params); cActionUri = rb_define_class_under(mPoppler, "ActionUri", cActionAny); DEFINE_ACTION_ACCESSOR(cActionUri, uri, uri); cActionNamed = rb_define_class_under(mPoppler, "ActionNamed", cActionAny); DEFINE_ACTION_ACCESSOR(cActionNamed, named, named_dest); cActionMovie = rb_define_class_under(mPoppler, "ActionMovie", cActionAny); actions[POPPLER_ACTION_UNKNOWN] = cActionAny; actions[POPPLER_ACTION_GOTO_DEST] = cActionGotoDest; actions[POPPLER_ACTION_GOTO_REMOTE] = cActionGotoRemote; actions[POPPLER_ACTION_LAUNCH] = cActionLaunch; actions[POPPLER_ACTION_URI] = cActionUri; actions[POPPLER_ACTION_NAMED] = cActionNamed; actions[POPPLER_ACTION_MOVIE] = cActionMovie; G_DEF_SETTERS(cAction); G_DEF_SETTERS(cActionAny); G_DEF_SETTERS(cActionGotoDest); G_DEF_SETTERS(cActionGotoRemote); G_DEF_SETTERS(cActionLaunch); G_DEF_SETTERS(cActionUri); G_DEF_SETTERS(cActionNamed); G_DEF_SETTERS(cActionMovie); G_DEF_CLASS(POPPLER_TYPE_ACTION_TYPE, "ActionType", mPoppler); G_DEF_CLASS(POPPLER_TYPE_DEST_TYPE, "DestType", mPoppler); cDest = G_DEF_CLASS(POPPLER_TYPE_DEST, "Dest", mPoppler); rb_define_method(cDest, "type", dest_get_type, 0); DEFINE_DEST_ACCESSOR(cDest, page_num); DEFINE_DEST_ACCESSOR(cDest, left); DEFINE_DEST_ACCESSOR(cDest, bottom); DEFINE_DEST_ACCESSOR(cDest, right); DEFINE_DEST_ACCESSOR(cDest, top); DEFINE_DEST_ACCESSOR(cDest, zoom); DEFINE_DEST_ACCESSOR(cDest, named_dest); DEFINE_DEST_ACCESSOR(cDest, change_left); DEFINE_DEST_ACCESSOR(cDest, change_top); DEFINE_DEST_ACCESSOR(cDest, change_zoom); G_DEF_SETTERS(cDest); }
/* * INIT */ void Init_ossl_pkcs7(void) { cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject); ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError); rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1); rb_define_singleton_method(cPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1); rb_define_singleton_method(cPKCS7, "sign", ossl_pkcs7_s_sign, -1); rb_define_singleton_method(cPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1); rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse); rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse); rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc); rb_define_copy_func(cPKCS7, ossl_pkcs7_copy); rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1); rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1); rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0); rb_define_method(cPKCS7, "detached=", ossl_pkcs7_set_detached, 1); rb_define_method(cPKCS7, "detached", ossl_pkcs7_get_detached, 0); rb_define_method(cPKCS7, "detached?", ossl_pkcs7_detached_p, 0); rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1); rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1); rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0); rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1); rb_define_method(cPKCS7, "recipients", ossl_pkcs7_get_recipient, 0); rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1); rb_define_method(cPKCS7, "certificates=", ossl_pkcs7_set_certificates, 1); rb_define_method(cPKCS7, "certificates", ossl_pkcs7_get_certificates, 0); rb_define_method(cPKCS7, "add_crl", ossl_pkcs7_add_crl, 1); rb_define_method(cPKCS7, "crls=", ossl_pkcs7_set_crls, 1); rb_define_method(cPKCS7, "crls", ossl_pkcs7_get_crls, 0); rb_define_method(cPKCS7, "add_data", ossl_pkcs7_add_data, 1); rb_define_alias(cPKCS7, "data=", "add_data"); rb_define_method(cPKCS7, "verify", ossl_pkcs7_verify, -1); rb_define_method(cPKCS7, "decrypt", ossl_pkcs7_decrypt, -1); rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0); rb_define_alias(cPKCS7, "to_s", "to_pem"); rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0); cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject); rb_define_const(cPKCS7, "Signer", cPKCS7Signer); rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc); rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3); rb_define_method(cPKCS7Signer, "issuer", ossl_pkcs7si_get_issuer, 0); rb_define_alias(cPKCS7Signer, "name", "issuer"); rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0); rb_define_method(cPKCS7Signer,"signed_time",ossl_pkcs7si_get_signed_time,0); cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject); rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc); rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1); rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0); rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0); rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0); #define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x)) DefPKCS7Const(TEXT); DefPKCS7Const(NOCERTS); DefPKCS7Const(NOSIGS); DefPKCS7Const(NOCHAIN); DefPKCS7Const(NOINTERN); DefPKCS7Const(NOVERIFY); DefPKCS7Const(DETACHED); DefPKCS7Const(BINARY); DefPKCS7Const(NOATTR); DefPKCS7Const(NOSMIMECAP); }
void Init_Collection (VALUE mXmms) { cColl = rb_define_class_under (mXmms, "Collection", rb_cObject); rb_define_alloc_func (cColl, c_alloc); rb_define_singleton_method (cColl, "universe", c_coll_universe, 0); rb_define_singleton_method (cColl, "parse", c_coll_parse, 1); rb_define_method (cColl, "initialize", c_coll_init, 1); /* type methods */ rb_define_method (cColl, "type", c_coll_type_get, 0); /* idlist methods */ rb_define_method (cColl, "idlist", c_coll_idlist_get, 0); rb_define_method (cColl, "idlist=", c_coll_idlist_set, 1); /* operand methods */ rb_define_method (cColl, "operands", c_coll_operands, 0); /* attribute methods */ rb_define_method (cColl, "attributes", c_coll_attributes, 0); rb_define_const (cColl, "NS_ALL", rb_str_new2 (XMMS_COLLECTION_NS_ALL)); rb_define_const (cColl, "NS_COLLECTIONS", rb_str_new2 (XMMS_COLLECTION_NS_COLLECTIONS)); rb_define_const (cColl, "NS_PLAYLISTS", rb_str_new2 (XMMS_COLLECTION_NS_PLAYLISTS)); DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_REFERENCE) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_UNIVERSE) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_UNION) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_INTERSECTION) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_COMPLEMENT) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_HAS) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_MATCH) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_TOKEN) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_EQUALS) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_NOTEQUAL) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_SMALLER) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_SMALLEREQ) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_GREATER) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_GREATEREQ) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_ORDER) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_LIMIT) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_MEDIASET) DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_IDLIST) DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, ADD) DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, UPDATE) DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, RENAME) DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, REMOVE) ePatternError = rb_define_class_under (cColl, "PatternError", rb_eStandardError); eCollectionError = rb_define_class_under (cColl, "CollectionError", rb_eStandardError); eClientError = rb_define_class_under (cColl, "ClientError", rb_eStandardError); eDisconnectedError = rb_define_class_under (cColl, "DisconnectedError", eClientError); cAttributes = rb_define_class_under (cColl, "Attributes", rb_cObject); rb_define_method (cAttributes, "initialize", c_attrs_init, 1); #ifdef HAVE_RB_PROTECT_INSPECT rb_define_method (cAttributes, "inspect", c_attrs_inspect, 0); #endif /* HAVE_RB_PROTECT_INSPECT */ rb_define_method (cAttributes, "[]", c_attrs_aref, 1); rb_define_method (cAttributes, "[]=", c_attrs_aset, 2); rb_define_method (cAttributes, "has_key?", c_attrs_has_key, 1); rb_define_method (cAttributes, "delete", c_attrs_delete, 1); rb_define_method (cAttributes, "each", c_attrs_each, 0); rb_define_method (cAttributes, "each_key", c_attrs_each_key, 0); rb_define_method (cAttributes, "each_value", c_attrs_each_value, 0); rb_define_alias (cAttributes, "include?", "has_key?"); rb_define_alias (cAttributes, "key?", "has_key?"); rb_define_alias (cAttributes, "member?", "has_key?"); rb_define_alias (cAttributes, "each_pair", "each"); rb_include_module (cAttributes, rb_mEnumerable); cOperands = rb_define_class_under (cColl, "Operands", rb_cObject); rb_define_method (cOperands, "initialize", c_operands_init, 1); rb_define_method (cOperands, "push", c_operands_push, 1); rb_define_method (cOperands, "delete", c_operands_delete, 1); rb_define_method (cOperands, "each", c_operands_each, 0); rb_define_alias (cOperands, "<<", "push"); rb_include_module (cOperands, rb_mEnumerable); }
void Init_rkerberos(){ mKerberos = rb_define_module("Kerberos"); cKrb5 = rb_define_class_under(mKerberos, "Krb5", rb_cObject); cKrb5Exception = rb_define_class_under(cKrb5, "Exception", rb_eStandardError); // Allocation functions rb_define_alloc_func(cKrb5, rkrb5_allocate); // Initializers rb_define_method(cKrb5, "initialize", rkrb5_initialize, 0); // Krb5 Methods rb_define_method(cKrb5, "change_password", rkrb5_change_password, 2); rb_define_method(cKrb5, "close", rkrb5_close, 0); rb_define_method(cKrb5, "get_default_realm", rkrb5_get_default_realm, 0); rb_define_method(cKrb5, "get_init_creds_password", rkrb5_get_init_creds_passwd, -1); rb_define_method(cKrb5, "get_init_creds_keytab", rkrb5_get_init_creds_keytab, -1); rb_define_method(cKrb5, "get_default_principal", rkrb5_get_default_principal, 0); rb_define_method(cKrb5, "get_permitted_enctypes", rkrb5_get_permitted_enctypes, 0); rb_define_method(cKrb5, "set_default_realm", rkrb5_set_default_realm, -1); // Aliases rb_define_alias(cKrb5, "default_realm", "get_default_realm"); rb_define_alias(cKrb5, "default_principal", "get_default_principal"); /* 0.1.0: The version of the custom rkerberos library */ rb_define_const(cKrb5, "VERSION", rb_str_new2("0.1.0")); // Encoding type constants /* 0: None */ rb_define_const(cKrb5, "ENCTYPE_NULL", INT2FIX(ENCTYPE_NULL)); /* 1: DES cbc mode with CRC-32 */ rb_define_const(cKrb5, "ENCTYPE_DES_CBC_CRC", INT2FIX(ENCTYPE_DES_CBC_CRC)); /* 2: DES cbc mode with RSA-MD4 */ rb_define_const(cKrb5, "ENCTYPE_DES_CBC_MD4", INT2FIX(ENCTYPE_DES_CBC_MD4)); /* 3: DES cbc mode with RSA-MD5 */ rb_define_const(cKrb5, "ENCTYPE_DES_CBC_MD5", INT2FIX(ENCTYPE_DES_CBC_MD5)); /* 4: DES cbc mode raw */ rb_define_const(cKrb5, "ENCTYPE_DES_CBC_RAW", INT2FIX(ENCTYPE_DES_CBC_RAW)); /* 5: DES-3 cbc mode with NIST-SHA */ rb_define_const(cKrb5, "ENCTYPE_DES3_CBC_SHA", INT2FIX(ENCTYPE_DES3_CBC_SHA)); /* 6: DES-3 cbc mode raw */ rb_define_const(cKrb5, "ENCTYPE_DES3_CBC_RAW", INT2FIX(ENCTYPE_DES3_CBC_RAW)); /* 8: HMAC SHA1 */ rb_define_const(cKrb5, "ENCTYPE_DES_HMAC_SHA1", INT2FIX(ENCTYPE_DES_HMAC_SHA1)); /* 9: DSA with SHA1, CMS signature */ rb_define_const(cKrb5, "ENCTYPE_DSA_SHA1_CMS", INT2FIX(ENCTYPE_DSA_SHA1_CMS)); /* 10: MD5 with RSA, CMS signature */ rb_define_const(cKrb5, "ENCTYPE_MD5_RSA_CMS", INT2FIX(ENCTYPE_MD5_RSA_CMS)); /* 11: SHA1 with RSA, CMS signature */ rb_define_const(cKrb5, "ENCTYPE_SHA1_RSA_CMS", INT2FIX(ENCTYPE_SHA1_RSA_CMS)); /* 12: RC2 cbc mode, CMS enveloped data */ rb_define_const(cKrb5, "ENCTYPE_RC2_CBC_ENV", INT2FIX(ENCTYPE_RC2_CBC_ENV)); /* 13: RSA encryption, CMS enveloped data */ rb_define_const(cKrb5, "ENCTYPE_RSA_ENV", INT2FIX(ENCTYPE_RSA_ENV)); /* 14: RSA w/OEAP encryption, CMS enveloped data */ rb_define_const(cKrb5, "ENCTYPE_RSA_ES_OAEP_ENV", INT2FIX(ENCTYPE_RSA_ES_OAEP_ENV)); /* 15: DES-3 cbc mode, CMS enveloped data */ rb_define_const(cKrb5, "ENCTYPE_DES3_CBC_ENV", INT2FIX(ENCTYPE_DES3_CBC_ENV)); /* 16: DES3 CBC SHA1 */ rb_define_const(cKrb5, "ENCTYPE_DES3_CBC_SHA1", INT2FIX(ENCTYPE_DES3_CBC_SHA1)); /* 17: AES128 CTS HMAC SHA1 96 */ rb_define_const(cKrb5, "ENCTYPE_AES128_CTS_HMAC_SHA1_96", INT2FIX(ENCTYPE_AES128_CTS_HMAC_SHA1_96)); /* 18: AES256 CTS HMAC SHA1 96 */ rb_define_const(cKrb5, "ENCTYPE_AES256_CTS_HMAC_SHA1_96", INT2FIX(ENCTYPE_AES256_CTS_HMAC_SHA1_96)); /* 23: ARCFOUR HMAC */ rb_define_const(cKrb5, "ENCTYPE_ARCFOUR_HMAC", INT2FIX(ENCTYPE_ARCFOUR_HMAC)); /* 24: ARCFOUR HMAC EXP */ rb_define_const(cKrb5, "ENCTYPE_ARCFOUR_HMAC_EXP", INT2FIX(ENCTYPE_ARCFOUR_HMAC_EXP)); /* 511: Unknown */ rb_define_const(cKrb5, "ENCTYPE_UNKNOWN", INT2FIX(ENCTYPE_UNKNOWN)); // Class initialization Init_context(); Init_ccache(); Init_kadm5(); Init_config(); Init_policy(); Init_principal(); Init_keytab(); Init_keytab_entry(); }
void Init_CPF(){ mBr = rb_define_module("BR"); cCpf = rb_define_class_under(mBr, "CPF", rb_cObject); rb_define_method(cCpf, "initialize", t_init_cpf, 1); rb_define_singleton_method(cCpf, "valid?", valid_cpf, 1); }
void Init_ossl_ssl() { int i; VALUE ary; #if 0 /* let rdoc know about mOSSL */ mOSSL = rb_define_module("OpenSSL"); #endif ID_callback_state = rb_intern("@callback_state"); ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_vcb_idx",0,0,0); ossl_ssl_ex_store_p = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_store_p",0,0,0); ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_ptr_idx",0,0,0); ossl_ssl_ex_client_cert_cb_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_client_cert_cb_idx",0,0,0); ossl_ssl_ex_tmp_dh_callback_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_tmp_dh_callback_idx",0,0,0); mSSL = rb_define_module_under(mOSSL, "SSL"); eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError); Init_ossl_ssl_session(); /* class SSLContext * * The following attributes are available but don't show up in rdoc. * All attributes must be set before calling SSLSocket.new(io, ctx). * * ssl_version, cert, key, client_ca, ca_file, ca_path, timeout, * * verify_mode, verify_depth client_cert_cb, tmp_dh_callback, * * session_id_context, session_add_cb, session_new_cb, session_remove_cb */ cSSLContext = rb_define_class_under(mSSL, "SSLContext", rb_cObject); rb_objc_define_method(*(VALUE *)cSSLContext, "alloc", ossl_sslctx_s_alloc, 0); for(i = 0; i < numberof(ossl_sslctx_attrs); i++) rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse); rb_define_alias(cSSLContext, "ssl_timeout", "timeout"); rb_define_alias(cSSLContext, "ssl_timeout=", "timeout="); rb_objc_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1); rb_objc_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1); rb_objc_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0); rb_objc_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1); rb_objc_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0); rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF)); rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */ rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER)); rb_define_const(cSSLContext, "SESSION_CACHE_BOTH", LONG2FIX(SSL_SESS_CACHE_BOTH)); /* no different than CACHE_SERVER in 0.9.8e */ rb_define_const(cSSLContext, "SESSION_CACHE_NO_AUTO_CLEAR", LONG2FIX(SSL_SESS_CACHE_NO_AUTO_CLEAR)); rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_LOOKUP", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)); rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_STORE", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_STORE)); rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL)); rb_objc_define_method(cSSLContext, "session_add", ossl_sslctx_session_add, 1); rb_objc_define_method(cSSLContext, "session_remove", ossl_sslctx_session_remove, 1); rb_objc_define_method(cSSLContext, "session_cache_mode", ossl_sslctx_get_session_cache_mode, 0); rb_objc_define_method(cSSLContext, "session_cache_mode=", ossl_sslctx_set_session_cache_mode, 1); rb_objc_define_method(cSSLContext, "session_cache_size", ossl_sslctx_get_session_cache_size, 0); rb_objc_define_method(cSSLContext, "session_cache_size=", ossl_sslctx_set_session_cache_size, 1); rb_objc_define_method(cSSLContext, "session_cache_stats", ossl_sslctx_get_session_cache_stats, 0); rb_objc_define_method(cSSLContext, "flush_sessions", ossl_sslctx_flush_sessions, -1); ary = rb_ary_new2(numberof(ossl_ssl_method_tab)); for (i = 0; i < numberof(ossl_ssl_method_tab); i++) { rb_ary_push(ary, ID2SYM(rb_intern(ossl_ssl_method_tab[i].name))); } rb_obj_freeze(ary); /* holds a list of available SSL/TLS methods */ rb_define_const(cSSLContext, "METHODS", ary); /* class SSLSocket * * The following attributes are available but don't show up in rdoc. * * io, context, sync_close * */ cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject); rb_objc_define_method(*(VALUE *)cSSLSocket, "alloc", ossl_ssl_s_alloc, 0); for(i = 0; i < numberof(ossl_ssl_attr_readers); i++) rb_attr(cSSLSocket, rb_intern(ossl_ssl_attr_readers[i]), 1, 0, Qfalse); for(i = 0; i < numberof(ossl_ssl_attrs); i++) rb_attr(cSSLSocket, rb_intern(ossl_ssl_attrs[i]), 1, 1, Qfalse); rb_define_alias(cSSLSocket, "to_io", "io"); rb_objc_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1); rb_objc_define_method(cSSLSocket, "connect", ossl_ssl_connect, 0); rb_objc_define_method(cSSLSocket, "connect_nonblock", ossl_ssl_connect_nonblock, 0); rb_objc_define_method(cSSLSocket, "accept", ossl_ssl_accept, 0); rb_objc_define_method(cSSLSocket, "accept_nonblock", ossl_ssl_accept_nonblock, 0); rb_objc_define_method(cSSLSocket, "sysread", ossl_ssl_read, -1); rb_objc_define_private_method(cSSLSocket, "sysread_nonblock", ossl_ssl_read_nonblock, -1); rb_objc_define_method(cSSLSocket, "syswrite", ossl_ssl_write, 1); rb_objc_define_private_method(cSSLSocket, "syswrite_nonblock", ossl_ssl_write_nonblock, 1); rb_objc_define_method(cSSLSocket, "sysclose", ossl_ssl_close, 0); rb_objc_define_method(cSSLSocket, "cert", ossl_ssl_get_cert, 0); rb_objc_define_method(cSSLSocket, "peer_cert", ossl_ssl_get_peer_cert, 0); rb_objc_define_method(cSSLSocket, "peer_cert_chain", ossl_ssl_get_peer_cert_chain, 0); rb_objc_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0); rb_objc_define_method(cSSLSocket, "state", ossl_ssl_get_state, 0); rb_objc_define_method(cSSLSocket, "pending", ossl_ssl_pending, 0); rb_objc_define_method(cSSLSocket, "session_reused?", ossl_ssl_session_reused, 0); rb_objc_define_method(cSSLSocket, "session=", ossl_ssl_set_session, 1); rb_objc_define_method(cSSLSocket, "verify_result", ossl_ssl_get_verify_result, 0); #define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, INT2NUM(SSL_##x)) ossl_ssl_def_const(VERIFY_NONE); ossl_ssl_def_const(VERIFY_PEER); ossl_ssl_def_const(VERIFY_FAIL_IF_NO_PEER_CERT); ossl_ssl_def_const(VERIFY_CLIENT_ONCE); /* Introduce constants included in OP_ALL. These constants are mostly for * unset some bits in OP_ALL such as; * ctx.options = OP_ALL & ~OP_DONT_INSERT_EMPTY_FRAGMENTS */ ossl_ssl_def_const(OP_MICROSOFT_SESS_ID_BUG); ossl_ssl_def_const(OP_NETSCAPE_CHALLENGE_BUG); ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG); ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG); ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER); ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING); ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG); ossl_ssl_def_const(OP_TLS_D5_BUG); ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG); ossl_ssl_def_const(OP_DONT_INSERT_EMPTY_FRAGMENTS); ossl_ssl_def_const(OP_ALL); #if defined(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION) ossl_ssl_def_const(OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); #endif #if defined(SSL_OP_SINGLE_ECDH_USE) ossl_ssl_def_const(OP_SINGLE_ECDH_USE); #endif ossl_ssl_def_const(OP_SINGLE_DH_USE); ossl_ssl_def_const(OP_EPHEMERAL_RSA); #if defined(SSL_OP_CIPHER_SERVER_PREFERENCE) ossl_ssl_def_const(OP_CIPHER_SERVER_PREFERENCE); #endif ossl_ssl_def_const(OP_TLS_ROLLBACK_BUG); ossl_ssl_def_const(OP_NO_SSLv2); ossl_ssl_def_const(OP_NO_SSLv3); ossl_ssl_def_const(OP_NO_TLSv1); #if defined(SSL_OP_NO_TICKET) ossl_ssl_def_const(OP_NO_TICKET); #endif ossl_ssl_def_const(OP_PKCS1_CHECK_1); ossl_ssl_def_const(OP_PKCS1_CHECK_2); ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG); ossl_ssl_def_const(OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG); ossl_lock_init(); }
// init void init_TranslationContent() { cTranslationContent = rb_define_class_under(GettextpoHelper, "TranslationContent", rb_cObject); rb_define_singleton_method(cTranslationContent, "new", RUBY_METHOD_FUNC(cTranslationContent_new_file), 1); rb_define_singleton_method(cTranslationContent, "new", RUBY_METHOD_FUNC(cTranslationContent_new_git), 2); }
void Init_Exception(void) { rb_eException = rb_define_class("Exception", rb_cObject); rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1); rb_define_method(rb_eException, "exception", exc_exception, -1); rb_define_method(rb_eException, "initialize", exc_initialize, -1); rb_define_method(rb_eException, "==", exc_equal, 1); rb_define_method(rb_eException, "to_s", exc_to_s, 0); rb_define_method(rb_eException, "message", exc_message, 0); rb_define_method(rb_eException, "inspect", exc_inspect, 0); rb_define_method(rb_eException, "backtrace", exc_backtrace, 0); rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1); rb_eSystemExit = rb_define_class("SystemExit", rb_eException); rb_define_method(rb_eSystemExit, "initialize", exit_initialize, -1); rb_define_method(rb_eSystemExit, "status", exit_status, 0); rb_define_method(rb_eSystemExit, "success?", exit_success_p, 0); rb_eFatal = rb_define_class("fatal", rb_eException); rb_eSignal = rb_define_class("SignalException", rb_eException); rb_eInterrupt = rb_define_class("Interrupt", rb_eSignal); rb_eStandardError = rb_define_class("StandardError", rb_eException); rb_eTypeError = rb_define_class("TypeError", rb_eStandardError); rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError); rb_eIndexError = rb_define_class("IndexError", rb_eStandardError); rb_eKeyError = rb_define_class("KeyError", rb_eIndexError); rb_eRangeError = rb_define_class("RangeError", rb_eStandardError); rb_eScriptError = rb_define_class("ScriptError", rb_eException); rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError); rb_eLoadError = rb_define_class("LoadError", rb_eScriptError); rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError); rb_eNameError = rb_define_class("NameError", rb_eScriptError); rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1); rb_define_method(rb_eNameError, "name", name_err_name, 0); rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0); rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData); rb_define_singleton_method(rb_cNameErrorMesg, "!", name_err_mesg_new, 3); rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1); rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0); rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1); rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1); rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError); rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1); rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0); rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError); rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError); rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException); syserr_tbl = st_init_numtable(); rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError); rb_define_method(rb_eSystemCallError, "initialize", syserr_initialize, -1); rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0); rb_define_singleton_method(rb_eSystemCallError, "===", syserr_eqq, 1); rb_mErrno = rb_define_module("Errno"); rb_define_singleton_method(rb_mErrno, "const_missing", errno_missing, 1); rb_define_global_function("warn", rb_warn_m, 1); }
void Init_cpBody(void) { c_cpBody = rb_define_class_under(m_Chipmunk, "Body", rb_cObject); rb_define_alloc_func(c_cpBody, rb_cpBodyAlloc); rb_define_method(c_cpBody, "initialize", rb_cpBodyInitialize, 2); c_cpStaticBody = rb_define_class_under(m_Chipmunk, "StaticBody", c_cpBody); rb_define_alloc_func(c_cpStaticBody, rb_cpBodyAlloc); // rb_define_alloc_func will not work here, since superclass defines this. // so, we define new here in stead. // rb_define_singleton_method(c_cpStaticBody, "new", rb_cpStaticBodyNew, 0); rb_define_method(c_cpStaticBody, "initialize", rb_cpBodyInitializeStatic, 0); rb_define_singleton_method(c_cpBody, "new_static", rb_cpStaticBodyNew, 0); rb_define_method(c_cpBody, "m", rb_cpBodyGetMass, 0); rb_define_method(c_cpBody, "i", rb_cpBodyGetMoment, 0); rb_define_method(c_cpBody, "p", rb_cpBodyGetPos, 0); rb_define_method(c_cpBody, "v", rb_cpBodyGetVel, 0); rb_define_method(c_cpBody, "f", rb_cpBodyGetForce, 0); rb_define_method(c_cpBody, "a", rb_cpBodyGetAngle, 0); rb_define_method(c_cpBody, "w", rb_cpBodyGetAVel, 0); rb_define_method(c_cpBody, "t", rb_cpBodyGetTorque, 0); rb_define_method(c_cpBody, "rot", rb_cpBodyGetRot, 0); rb_define_method(c_cpBody, "m=", rb_cpBodySetMass, 1); rb_define_method(c_cpBody, "i=", rb_cpBodySetMoment, 1); rb_define_method(c_cpBody, "p=", rb_cpBodySetPos, 1); rb_define_method(c_cpBody, "v=", rb_cpBodySetVel, 1); rb_define_method(c_cpBody, "f=", rb_cpBodySetForce, 1); rb_define_method(c_cpBody, "a=", rb_cpBodySetAngle, 1); rb_define_method(c_cpBody, "w=", rb_cpBodySetAVel, 1); rb_define_method(c_cpBody, "t=", rb_cpBodySetTorque, 1); rb_define_method(c_cpBody, "mass", rb_cpBodyGetMass, 0); rb_define_method(c_cpBody, "moment", rb_cpBodyGetMoment, 0); rb_define_method(c_cpBody, "pos", rb_cpBodyGetPos, 0); rb_define_method(c_cpBody, "vel", rb_cpBodyGetVel, 0); rb_define_method(c_cpBody, "force", rb_cpBodyGetForce, 0); rb_define_method(c_cpBody, "angle", rb_cpBodyGetAngle, 0); rb_define_method(c_cpBody, "ang_vel", rb_cpBodyGetAVel, 0); rb_define_method(c_cpBody, "torque", rb_cpBodyGetTorque, 0); rb_define_method(c_cpBody, "rot", rb_cpBodyGetRot, 0); rb_define_method(c_cpBody, "m_inv", rb_cpBodyGetMassInv, 0); rb_define_method(c_cpBody, "mass_inv", rb_cpBodyGetMassInv, 0); rb_define_method(c_cpBody, "moment_inv", rb_cpBodyGetMomentInv, 0); rb_define_method(c_cpBody, "v_limit", rb_cpBodyGetVLimit, 0); rb_define_method(c_cpBody, "w_limit", rb_cpBodyGetWLimit, 0); rb_define_method(c_cpBody, "mass=", rb_cpBodySetMass, 1); rb_define_method(c_cpBody, "moment=", rb_cpBodySetMoment, 1); rb_define_method(c_cpBody, "pos=", rb_cpBodySetPos, 1); rb_define_method(c_cpBody, "vel=", rb_cpBodySetVel, 1); rb_define_method(c_cpBody, "force=", rb_cpBodySetForce, 1); rb_define_method(c_cpBody, "angle=", rb_cpBodySetAngle, 1); rb_define_method(c_cpBody, "ang_vel=", rb_cpBodySetAVel, 1); rb_define_method(c_cpBody, "torque=", rb_cpBodySetTorque, 1); rb_define_method(c_cpBody, "v_limit=", rb_cpBodySetVLimit, 1); rb_define_method(c_cpBody, "w_limit=", rb_cpBodySetWLimit, 1); rb_define_method(c_cpBody, "local2world", rb_cpBodyLocal2World, 1); rb_define_method(c_cpBody, "world2local", rb_cpBodyWorld2Local, 1); rb_define_method(c_cpBody, "reset_forces", rb_cpBodyResetForces, 0); rb_define_method(c_cpBody, "apply_force", rb_cpBodyApplyForce, 2); rb_define_method(c_cpBody, "apply_impulse", rb_cpBodyApplyImpulse, 2); rb_define_method(c_cpBody, "update_velocity", rb_cpBodyUpdateVelocity, 3); rb_define_method(c_cpBody, "update_position", rb_cpBodyUpdatePosition, 1); rb_define_method(c_cpBody, "static?", rb_cpBodyIsStatic, 0); rb_define_method(c_cpBody, "rogue?", rb_cpBodyIsRogue, 0); rb_define_method(c_cpBody, "sleeping?", rb_cpBodyIsSleeping, 0); rb_define_method(c_cpBody, "sleep?", rb_cpBodyIsSleeping, 0); rb_define_method(c_cpBody, "sleep_with_self", rb_cpBodySleep, 0); rb_define_method(c_cpBody, "sleep_self", rb_cpBodySleep, 0); rb_define_method(c_cpBody, "sleep_alone", rb_cpBodySleep, 0); rb_define_method(c_cpBody, "sleep_with_group", rb_cpBodySleepWithGroup, 1); rb_define_method(c_cpBody, "sleep_group", rb_cpBodySleepWithGroup, 1); rb_define_method(c_cpBody, "activate", rb_cpBodyActivate, 0); rb_define_method(c_cpBody, "velocity_func", rb_cpBodySetVelocityFunc, -1); rb_define_method(c_cpBody, "position_func", rb_cpBodySetPositionFunc, -1); rb_define_method(c_cpBody, "object=", rb_cpBodySetData, 1); rb_define_method(c_cpBody, "object", rb_cpBodyGetData, 0); rb_define_method(c_cpBody, "kinetic_energy", rb_cpBodyKineticEnergy, 0); }
void rbffi_AbstractMemory_Init(VALUE moduleFFI) { /* * Document-class: FFI::AbstractMemory * * {AbstractMemory} is the base class for many memory management classes such as {Buffer}. * * This class has a lot of methods to work with integers : * * put_int<i>size</i>(offset, value) * * get_int<i>size</i>(offset) * * put_uint<i>size</i>(offset, value) * * get_uint<i>size</i>(offset) * * writeuint<i>size</i>(value) * * read_int<i>size</i> * * write_uint<i>size</i>(value) * * read_uint<i>size</i> * * put_array_of_int<i>size</i>(offset, ary) * * get_array_of_int<i>size</i>(offset, length) * * put_array_of_uint<i>size</i>(offset, ary) * * get_array_of_uint<i>size</i>(offset, length) * * write_array_of_int<i>size</i>(ary) * * read_array_of_int<i>size</i>(length) * * write_array_of_uint<i>size</i>(ary) * * read_array_of_uint<i>size</i>(length) * where _size_ is 8, 16, 32 or 64. Same methods exist for long type. * * Aliases exist : _char_ for _int8_, _short_ for _int16_, _int_ for _int32_ and <i>long_long</i> for _int64_. * * Others methods are listed below. */ VALUE classMemory = rb_define_class_under(moduleFFI, "AbstractMemory", rb_cObject); rbffi_AbstractMemoryClass = classMemory; /* * Document-variable: FFI::AbstractMemory */ rb_global_variable(&rbffi_AbstractMemoryClass); rb_define_alloc_func(classMemory, memory_allocate); NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError); /* Document-variable: NullPointerError */ rb_global_variable(&NullPointerErrorClass); #undef INT #define INT(type) \ rb_define_method(classMemory, "put_" #type, memory_put_##type, 2); \ rb_define_method(classMemory, "get_" #type, memory_get_##type, 1); \ rb_define_method(classMemory, "put_u" #type, memory_put_u##type, 2); \ rb_define_method(classMemory, "get_u" #type, memory_get_u##type, 1); \ rb_define_method(classMemory, "write_" #type, memory_write_##type, 1); \ rb_define_method(classMemory, "read_" #type, memory_read_##type, 0); \ rb_define_method(classMemory, "write_u" #type, memory_write_u##type, 1); \ rb_define_method(classMemory, "read_u" #type, memory_read_u##type, 0); \ rb_define_method(classMemory, "put_array_of_" #type, memory_put_array_of_##type, 2); \ rb_define_method(classMemory, "get_array_of_" #type, memory_get_array_of_##type, 2); \ rb_define_method(classMemory, "put_array_of_u" #type, memory_put_array_of_u##type, 2); \ rb_define_method(classMemory, "get_array_of_u" #type, memory_get_array_of_u##type, 2); \ rb_define_method(classMemory, "write_array_of_" #type, memory_write_array_of_##type, 1); \ rb_define_method(classMemory, "read_array_of_" #type, memory_read_array_of_##type, 1); \ rb_define_method(classMemory, "write_array_of_u" #type, memory_write_array_of_u##type, 1); \ rb_define_method(classMemory, "read_array_of_u" #type, memory_read_array_of_u##type, 1); INT(int8); INT(int16); INT(int32); INT(int64); INT(long); #define ALIAS(name, old) \ rb_define_alias(classMemory, "put_" #name, "put_" #old); \ rb_define_alias(classMemory, "get_" #name, "get_" #old); \ rb_define_alias(classMemory, "put_u" #name, "put_u" #old); \ rb_define_alias(classMemory, "get_u" #name, "get_u" #old); \ rb_define_alias(classMemory, "write_" #name, "write_" #old); \ rb_define_alias(classMemory, "read_" #name, "read_" #old); \ rb_define_alias(classMemory, "write_u" #name, "write_u" #old); \ rb_define_alias(classMemory, "read_u" #name, "read_u" #old); \ rb_define_alias(classMemory, "put_array_of_" #name, "put_array_of_" #old); \ rb_define_alias(classMemory, "get_array_of_" #name, "get_array_of_" #old); \ rb_define_alias(classMemory, "put_array_of_u" #name, "put_array_of_u" #old); \ rb_define_alias(classMemory, "get_array_of_u" #name, "get_array_of_u" #old); \ rb_define_alias(classMemory, "write_array_of_" #name, "write_array_of_" #old); \ rb_define_alias(classMemory, "read_array_of_" #name, "read_array_of_" #old); \ rb_define_alias(classMemory, "write_array_of_u" #name, "write_array_of_u" #old); \ rb_define_alias(classMemory, "read_array_of_u" #name, "read_array_of_u" #old); ALIAS(char, int8); ALIAS(short, int16); ALIAS(int, int32); ALIAS(long_long, int64); /* * Document-method: put_float32 * call-seq: memory.put_float32offset, value) * @param [Numeric] offset * @param [Numeric] value * @return [self] * Put +value+ as a 32-bit float in memory at offset +offset+ (alias: #put_float). */ rb_define_method(classMemory, "put_float32", memory_put_float32, 2); /* * Document-method: get_float32 * call-seq: memory.get_float32(offset) * @param [Numeric] offset * @return [Float] * Get a 32-bit float from memory at offset +offset+ (alias: #get_float). */ rb_define_method(classMemory, "get_float32", memory_get_float32, 1); rb_define_alias(classMemory, "put_float", "put_float32"); rb_define_alias(classMemory, "get_float", "get_float32"); /* * Document-method: write_float * call-seq: memory.write_float(value) * @param [Numeric] value * @return [self] * Write +value+ as a 32-bit float in memory. * * Same as: * memory.put_float(0, value) */ rb_define_method(classMemory, "write_float", memory_write_float32, 1); /* * Document-method: read_float * call-seq: memory.read_float * @return [Float] * Read a 32-bit float from memory. * * Same as: * memory.get_float(0) */ rb_define_method(classMemory, "read_float", memory_read_float32, 0); /* * Document-method: put_array_of_float32 * call-seq: memory.put_array_of_float32(offset, ary) * @param [Numeric] offset * @param [Array<Numeric>] ary * @return [self] * Put values from +ary+ as 32-bit floats in memory from offset +offset+ (alias: #put_array_of_float). */ rb_define_method(classMemory, "put_array_of_float32", memory_put_array_of_float32, 2); /* * Document-method: get_array_of_float32 * call-seq: memory.get_array_of_float32(offset, length) * @param [Numeric] offset * @param [Numeric] length number of Float to get * @return [Array<Float>] * Get 32-bit floats in memory from offset +offset+ (alias: #get_array_of_float). */ rb_define_method(classMemory, "get_array_of_float32", memory_get_array_of_float32, 2); /* * Document-method: write_array_of_float * call-seq: memory.write_array_of_float(ary) * @param [Array<Numeric>] ary * @return [self] * Write values from +ary+ as 32-bit floats in memory. * * Same as: * memory.put_array_of_float(0, ary) */ rb_define_method(classMemory, "write_array_of_float", memory_write_array_of_float32, 1); /* * Document-method: read_array_of_float * call-seq: memory.read_array_of_float(length) * @param [Numeric] length number of Float to read * @return [Array<Float>] * Read 32-bit floats from memory. * * Same as: * memory.get_array_of_float(0, ary) */ rb_define_method(classMemory, "read_array_of_float", memory_read_array_of_float32, 1); rb_define_alias(classMemory, "put_array_of_float", "put_array_of_float32"); rb_define_alias(classMemory, "get_array_of_float", "get_array_of_float32"); /* * Document-method: put_float64 * call-seq: memory.put_float64(offset, value) * @param [Numeric] offset * @param [Numeric] value * @return [self] * Put +value+ as a 64-bit float (double) in memory at offset +offset+ (alias: #put_double). */ rb_define_method(classMemory, "put_float64", memory_put_float64, 2); /* * Document-method: get_float64 * call-seq: memory.get_float64(offset) * @param [Numeric] offset * @return [Float] * Get a 64-bit float (double) from memory at offset +offset+ (alias: #get_double). */ rb_define_method(classMemory, "get_float64", memory_get_float64, 1); rb_define_alias(classMemory, "put_double", "put_float64"); rb_define_alias(classMemory, "get_double", "get_float64"); /* * Document-method: write_double * call-seq: memory.write_double(value) * @param [Numeric] value * @return [self] * Write +value+ as a 64-bit float (double) in memory. * * Same as: * memory.put_double(0, value) */ rb_define_method(classMemory, "write_double", memory_write_float64, 1); /* * Document-method: read_double * call-seq: memory.read_double * @return [Float] * Read a 64-bit float (double) from memory. * * Same as: * memory.get_double(0) */ rb_define_method(classMemory, "read_double", memory_read_float64, 0); /* * Document-method: put_array_of_float64 * call-seq: memory.put_array_of_float64(offset, ary) * @param [Numeric] offset * @param [Array<Numeric>] ary * @return [self] * Put values from +ary+ as 64-bit floats (doubles) in memory from offset +offset+ (alias: #put_array_of_double). */ rb_define_method(classMemory, "put_array_of_float64", memory_put_array_of_float64, 2); /* * Document-method: get_array_of_float64 * call-seq: memory.get_array_of_float64(offset, length) * @param [Numeric] offset * @param [Numeric] length number of Float to get * @return [Array<Float>] * Get 64-bit floats (doubles) in memory from offset +offset+ (alias: #get_array_of_double). */ rb_define_method(classMemory, "get_array_of_float64", memory_get_array_of_float64, 2); /* * Document-method: write_array_of_double * call-seq: memory.write_array_of_double(ary) * @param [Array<Numeric>] ary * @return [self] * Write values from +ary+ as 64-bit floats (doubles) in memory. * * Same as: * memory.put_array_of_double(0, ary) */ rb_define_method(classMemory, "write_array_of_double", memory_write_array_of_float64, 1); /* * Document-method: read_array_of_double * call-seq: memory.read_array_of_double(length) * @param [Numeric] length number of Float to read * @return [Array<Float>] * Read 64-bit floats (doubles) from memory. * * Same as: * memory.get_array_of_double(0, ary) */ rb_define_method(classMemory, "read_array_of_double", memory_read_array_of_float64, 1); rb_define_alias(classMemory, "put_array_of_double", "put_array_of_float64"); rb_define_alias(classMemory, "get_array_of_double", "get_array_of_float64"); /* * Document-method: put_pointer * call-seq: memory.put_pointer(offset, value) * @param [Numeric] offset * @param [nil,Pointer, Integer, #to_ptr] value * @return [self] * Put +value+ in memory from +offset+.. */ rb_define_method(classMemory, "put_pointer", memory_put_pointer, 2); /* * Document-method: get_pointer * call-seq: memory.get_pointer(offset) * @param [Numeric] offset * @return [Pointer] * Get a {Pointer} to the memory from +offset+. */ rb_define_method(classMemory, "get_pointer", memory_get_pointer, 1); /* * Document-method: write_pointer * call-seq: memory.write_pointer(value) * @param [nil,Pointer, Integer, #to_ptr] value * @return [self] * Write +value+ in memory. * * Equivalent to: * memory.put_pointer(0, value) */ rb_define_method(classMemory, "write_pointer", memory_write_pointer, 1); /* * Document-method: read_pointer * call-seq: memory.read_pointer * @return [Pointer] * Get a {Pointer} to the memory from base address. * * Equivalent to: * memory.get_pointer(0) */ rb_define_method(classMemory, "read_pointer", memory_read_pointer, 0); /* * Document-method: put_array_of_pointer * call-seq: memory.put_array_of_pointer(offset, ary) * @param [Numeric] offset * @param [Array<#to_ptr>] ary * @return [self] * Put an array of {Pointer} into memory from +offset+. */ rb_define_method(classMemory, "put_array_of_pointer", memory_put_array_of_pointer, 2); /* * Document-method: get_array_of_pointer * call-seq: memory.get_array_of_pointer(offset, length) * @param [Numeric] offset * @param [Numeric] length * @return [Array<Pointer>] * Get an array of {Pointer} of length +length+ from +offset+. */ rb_define_method(classMemory, "get_array_of_pointer", memory_get_array_of_pointer, 2); /* * Document-method: write_array_of_pointer * call-seq: memory.write_array_of_pointer(ary) * @param [Array<#to_ptr>] ary * @return [self] * Write an array of {Pointer} into memory from +offset+. * * Same as : * memory.put_array_of_pointer(0, ary) */ rb_define_method(classMemory, "write_array_of_pointer", memory_write_array_of_pointer, 1); /* * Document-method: read_array_of_pointer * call-seq: memory.read_array_of_pointer(length) * @param [Numeric] length * @return [Array<Pointer>] * Read an array of {Pointer} of length +length+. * * Same as: * memory.get_array_of_pointer(0, length) */ rb_define_method(classMemory, "read_array_of_pointer", memory_read_array_of_pointer, 1); rb_define_method(classMemory, "get_string", memory_get_string, -1); rb_define_method(classMemory, "put_string", memory_put_string, 2); rb_define_method(classMemory, "get_bytes", memory_get_bytes, 2); rb_define_method(classMemory, "put_bytes", memory_put_bytes, -1); rb_define_method(classMemory, "read_bytes", memory_read_bytes, 1); rb_define_method(classMemory, "write_bytes", memory_write_bytes, -1); rb_define_method(classMemory, "get_array_of_string", memory_get_array_of_string, -1); rb_define_method(classMemory, "clear", memory_clear, 0); rb_define_method(classMemory, "total", memory_size, 0); rb_define_alias(classMemory, "size", "total"); rb_define_method(classMemory, "type_size", memory_type_size, 0); rb_define_method(classMemory, "[]", memory_aref, 1); rb_define_method(classMemory, "__copy_from__", memory_copy_from, 2); id_to_ptr = rb_intern("to_ptr"); id_call = rb_intern("call"); id_plus = rb_intern("+"); }
void rbffi_Struct_Init(VALUE moduleFFI) { VALUE StructClass; rbffi_StructLayout_Init(moduleFFI); rbffi_StructClass = StructClass = rb_define_class_under(moduleFFI, "Struct", rb_cObject); rb_global_variable(&rbffi_StructClass); rbffi_StructInlineArrayClass = rb_define_class_under(rbffi_StructClass, "InlineArray", rb_cObject); rb_global_variable(&rbffi_StructInlineArrayClass); rbffi_StructLayoutCharArrayClass = rb_define_class_under(rbffi_StructLayoutClass, "CharArray", rbffi_StructInlineArrayClass); rb_global_variable(&rbffi_StructLayoutCharArrayClass); rb_define_alloc_func(StructClass, struct_allocate); rb_define_method(StructClass, "initialize", struct_initialize, -1); rb_define_method(StructClass, "initialize_copy", struct_initialize_copy, 1); rb_define_method(StructClass, "order", struct_order, -1); rb_define_alias(rb_singleton_class(StructClass), "alloc_in", "new"); rb_define_alias(rb_singleton_class(StructClass), "alloc_out", "new"); rb_define_alias(rb_singleton_class(StructClass), "alloc_inout", "new"); rb_define_alias(rb_singleton_class(StructClass), "new_in", "new"); rb_define_alias(rb_singleton_class(StructClass), "new_out", "new"); rb_define_alias(rb_singleton_class(StructClass), "new_inout", "new"); rb_define_method(StructClass, "pointer", struct_get_pointer, 0); rb_define_private_method(StructClass, "pointer=", struct_set_pointer, 1); rb_define_method(StructClass, "layout", struct_get_layout, 0); rb_define_private_method(StructClass, "layout=", struct_set_layout, 1); rb_define_method(StructClass, "[]", struct_aref, 1); rb_define_method(StructClass, "[]=", struct_aset, 2); rb_define_method(StructClass, "null?", struct_null_p, 0); rb_include_module(rbffi_StructInlineArrayClass, rb_mEnumerable); rb_define_alloc_func(rbffi_StructInlineArrayClass, inline_array_allocate); rb_define_method(rbffi_StructInlineArrayClass, "initialize", inline_array_initialize, 2); rb_define_method(rbffi_StructInlineArrayClass, "[]", inline_array_aref, 1); rb_define_method(rbffi_StructInlineArrayClass, "[]=", inline_array_aset, 2); rb_define_method(rbffi_StructInlineArrayClass, "each", inline_array_each, 0); rb_define_method(rbffi_StructInlineArrayClass, "size", inline_array_size, 0); rb_define_method(rbffi_StructInlineArrayClass, "to_a", inline_array_to_a, 0); rb_define_method(rbffi_StructInlineArrayClass, "to_ptr", inline_array_to_ptr, 0); rb_define_method(rbffi_StructLayoutCharArrayClass, "to_s", inline_array_to_s, 0); rb_define_alias(rbffi_StructLayoutCharArrayClass, "to_str", "to_s"); id_pointer_ivar = rb_intern("@pointer"); id_layout_ivar = rb_intern("@layout"); id_layout = rb_intern("layout"); id_get = rb_intern("get"); id_put = rb_intern("put"); id_to_ptr = rb_intern("to_ptr"); id_to_s = rb_intern("to_s"); }
void Init_statgrab(void) { /* * = Statgrab for Ruby * * Bindings to the libstatgrab portable system statistics library. * * == API * * All instance methods except user_stats return symbol hashes or * arrays of symbol hashes corresponding to their C struct * counterparts, see libstatgrab manuals for reference. Also, +enum+ * datatypes are represented as lowercased symbols with namespacing * cut off, e.g. +SG_IFACE_DUPLEX_FULL+ becomes <tt>:full</tt>. * Errors are handled and raises corresponding exceptions, all * inheriting from Statgrab::Exception. Byte values are represented * in kilobytes. * * == Sample program * * require 'statgrab' * begin * sg = Statgrab.new * puts "CPU Usage: %.1f%%" % sg.cpu_percents[:user] * rescue Statgrab::Exception => e * puts "Error! %s" % e.message * end */ cStatgrab = rb_define_class("Statgrab", rb_cObject); rb_define_const(cStatgrab, "VERSION", rb_str_new2("0.1")); /* * Raised when a statgrab function failed and an error was set. */ eStatgrabException = rb_define_class_under(cStatgrab, "Exception", rb_eException); eStatgrabAsprintfError = rb_define_class_under(cStatgrab, "AsprintfError", eStatgrabException); eStatgrabDevicesError = rb_define_class_under(cStatgrab, "DevicesError", eStatgrabException); eStatgrabDevstatGetdevsError = rb_define_class_under(cStatgrab, "DevstatGetdevsError", eStatgrabException); eStatgrabDevstatSelectdevsError = rb_define_class_under(cStatgrab, "DevstatSelectdevsError", eStatgrabException); eStatgrabDiskinfoError = rb_define_class_under(cStatgrab, "DiskinfoError", eStatgrabException); eStatgrabEnoentError = rb_define_class_under(cStatgrab, "EnoentError", eStatgrabException); eStatgrabGetifaddrsError = rb_define_class_under(cStatgrab, "GetifaddrsError", eStatgrabException); eStatgrabGetmntinfoError = rb_define_class_under(cStatgrab, "GetmntinfoError", eStatgrabException); eStatgrabGetpagesizeError = rb_define_class_under(cStatgrab, "GetpagesizeError", eStatgrabException); eStatgrabHostError = rb_define_class_under(cStatgrab, "HostError", eStatgrabException); eStatgrabKstatDataLookupError = rb_define_class_under(cStatgrab, "KstatDataLookupError", eStatgrabException); eStatgrabKstatLookupError = rb_define_class_under(cStatgrab, "KstatLookupError", eStatgrabException); eStatgrabKstatOpenError = rb_define_class_under(cStatgrab, "KstatOpenError", eStatgrabException); eStatgrabKstatReadError = rb_define_class_under(cStatgrab, "KstatReadError", eStatgrabException); eStatgrabKvmGetswapinfoError = rb_define_class_under(cStatgrab, "KvmGetswapinfoError", eStatgrabException); eStatgrabKvmOpenfilesError = rb_define_class_under(cStatgrab, "KvmOpenfilesError", eStatgrabException); eStatgrabMallocError = rb_define_class_under(cStatgrab, "MallocError", eStatgrabException); eStatgrabMemstatusError = rb_define_class_under(cStatgrab, "MemstatusError", eStatgrabException); eStatgrabOpenError = rb_define_class_under(cStatgrab, "OpenError", eStatgrabException); eStatgrabOpendirError = rb_define_class_under(cStatgrab, "OpendirError", eStatgrabException); eStatgrabParseError = rb_define_class_under(cStatgrab, "ParseError", eStatgrabException); eStatgrabPdhaddError = rb_define_class_under(cStatgrab, "PdhaddError", eStatgrabException); eStatgrabPdhcollectError = rb_define_class_under(cStatgrab, "PdhcollectError", eStatgrabException); eStatgrabPdhopenError = rb_define_class_under(cStatgrab, "PdhopenError", eStatgrabException); eStatgrabPdhreadError = rb_define_class_under(cStatgrab, "PdhreadError", eStatgrabException); eStatgrabPermissionError = rb_define_class_under(cStatgrab, "PermissionError", eStatgrabException); eStatgrabPstatError = rb_define_class_under(cStatgrab, "PstatError", eStatgrabException); eStatgrabSetegidError = rb_define_class_under(cStatgrab, "SetegidError", eStatgrabException); eStatgrabSeteuidError = rb_define_class_under(cStatgrab, "SeteuidError", eStatgrabException); eStatgrabSetmntentError = rb_define_class_under(cStatgrab, "SetmntentError", eStatgrabException); eStatgrabSocketError = rb_define_class_under(cStatgrab, "SocketError", eStatgrabException); eStatgrabSwapctlError = rb_define_class_under(cStatgrab, "SwapctlError", eStatgrabException); eStatgrabSysconfError = rb_define_class_under(cStatgrab, "SysconfError", eStatgrabException); eStatgrabSysctlError = rb_define_class_under(cStatgrab, "SysctlError", eStatgrabException); eStatgrabSysctlbynameError = rb_define_class_under(cStatgrab, "SysctlbynameError", eStatgrabException); eStatgrabSysctlnametomibError = rb_define_class_under(cStatgrab, "SysctlnametomibError", eStatgrabException); eStatgrabUnameError = rb_define_class_under(cStatgrab, "UnameError", eStatgrabException); eStatgrabUnsupportedError = rb_define_class_under(cStatgrab, "UnsupportedError", eStatgrabException); eStatgrabXswVerMismatchError = rb_define_class_under(cStatgrab, "XswVerMismatchError", eStatgrabException); /* * Methods */ rb_define_method(cStatgrab, "initialize", statgrab_initialize, -2); rb_define_method(cStatgrab, "cpu_stats", statgrab_cpu_stats, 0); rb_define_alias(cStatgrab, "cpu", "cpu_stats"); rb_define_method(cStatgrab, "cpu_stats_diff", statgrab_cpu_stats_diff, 0); rb_define_alias(cStatgrab, "cpu_difference", "cpu_stats_diff"); rb_define_method(cStatgrab, "cpu_percents", statgrab_cpu_percents, 0); rb_define_method(cStatgrab, "disk_io_stats", statgrab_disk_io_stats, 0); rb_define_alias(cStatgrab, "disk_io", "disk_io_stats"); rb_define_method(cStatgrab, "disk_io_stats_diff", statgrab_disk_io_stats_diff, 0); rb_define_alias(cStatgrab, "disk_io_difference", "disk_io_stats_diff"); rb_define_method(cStatgrab, "fs_stats", statgrab_fs_stats, 0); rb_define_alias(cStatgrab, "fs", "fs_stats"); rb_define_alias(cStatgrab, "file_system", "fs_stats"); rb_define_method(cStatgrab, "host_info", statgrab_host_info, 0); rb_define_alias(cStatgrab, "host", "host_info"); rb_define_alias(cStatgrab, "system", "host_info"); rb_define_method(cStatgrab, "load_stats", statgrab_load_stats, 0); rb_define_alias(cStatgrab, "load", "load_stats"); rb_define_alias(cStatgrab, "loadavg", "load_stats"); rb_define_alias(cStatgrab, "load_average", "load_stats"); rb_define_alias(cStatgrab, "system_load", "load_stats"); rb_define_method(cStatgrab, "mem_stats", statgrab_mem_stats, 0); rb_define_alias(cStatgrab, "memory", "mem_stats"); rb_define_method(cStatgrab, "swap_stats", statgrab_swap_stats, 0); rb_define_alias(cStatgrab, "swap", "swap_stats"); rb_define_method(cStatgrab, "network_io_stats", statgrab_network_io_stats, 0); rb_define_alias(cStatgrab, "network_io", "network_io_stats"); rb_define_alias(cStatgrab, "net_io", "network_io_stats"); rb_define_alias(cStatgrab, "network", "network_io_stats"); rb_define_alias(cStatgrab, "net", "network_io_stats"); rb_define_method(cStatgrab, "network_io_stats_diff", statgrab_network_io_stats_diff, 0); rb_define_alias(cStatgrab, "network_io_difference", "network_io_stats_diff"); rb_define_alias(cStatgrab, "network_difference", "network_io_stats_diff"); rb_define_alias(cStatgrab, "net_difference", "network_io_stats_diff"); rb_define_method(cStatgrab, "network_iface_stats", statgrab_network_iface_stats, 0); rb_define_alias(cStatgrab, "network_iface", "network_iface_stats"); rb_define_alias(cStatgrab, "net_iface", "network_iface_stats"); rb_define_alias(cStatgrab, "iface", "network_iface_stats"); rb_define_method(cStatgrab, "page_stats", statgrab_page_stats, 0); rb_define_alias(cStatgrab, "page", "page_stats"); rb_define_alias(cStatgrab, "pages", "page_stats"); rb_define_method(cStatgrab, "page_stats_diff", statgrab_page_stats_diff, 0); rb_define_alias(cStatgrab, "page_difference", "page_stats_diff"); rb_define_method(cStatgrab, "process_stats", statgrab_process_stats, 0); rb_define_alias(cStatgrab, "process", "process_stats"); rb_define_alias(cStatgrab, "processes", "process_stats"); rb_define_alias(cStatgrab, "proc", "process_stats"); rb_define_alias(cStatgrab, "ps", "process_stats"); rb_define_method(cStatgrab, "process_count", statgrab_process_count, 0); rb_define_alias(cStatgrab, "proc_count", "process_count"); rb_define_method(cStatgrab, "user_stats", statgrab_user_stats, 0); rb_define_alias(cStatgrab, "users", "user_stats"); }
void init_curb_errors() { mCurlErr = rb_define_module_under(mCurl, "Err"); eCurlErrError = rb_define_class_under(mCurlErr, "CurlError", rb_eRuntimeError); eCurlErrFTPError = rb_define_class_under(mCurlErr, "FTPError", eCurlErrError); eCurlErrHTTPError = rb_define_class_under(mCurlErr, "HTTPError", eCurlErrError); eCurlErrFileError = rb_define_class_under(mCurlErr, "FileError", eCurlErrError); eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError); eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError); eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError); eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError); eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError); eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError); eCurlErrMalformedURLUser = rb_define_class_under(mCurlErr, "MalformedURLUserError", eCurlErrError); eCurlErrProxyResolution = rb_define_class_under(mCurlErr, "ProxyResolutionError", eCurlErrError); eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError); eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError); eCurlErrFTPWierdReply = rb_define_class_under(mCurlErr, "WierdReplyError", eCurlErrFTPError); eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError); eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadBasswordError", eCurlErrFTPError); eCurlErrFTPWierdPassReply = rb_define_class_under(mCurlErr, "WierdPassReplyError", eCurlErrFTPError); eCurlErrFTPWierdUserReply = rb_define_class_under(mCurlErr, "WierdUserReplyError", eCurlErrFTPError); eCurlErrFTPWierdPasvReply = rb_define_class_under(mCurlErr, "WierdPasvReplyError", eCurlErrFTPError); eCurlErrFTPWierd227Format = rb_define_class_under(mCurlErr, "Wierd227FormatError", eCurlErrFTPError); eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError); eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError); eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError); eCurlErrPartialFile = rb_define_class_under(mCurlErr, "PartialFileError", eCurlErrError); eCurlErrFTPCouldntRetrFile = rb_define_class_under(mCurlErr, "CouldntRetrFileError", eCurlErrFTPError); eCurlErrFTPWrite = rb_define_class_under(mCurlErr, "FTPWriteError", eCurlErrFTPError); eCurlErrFTPQuote = rb_define_class_under(mCurlErr, "FTPQuoteError", eCurlErrFTPError); eCurlErrHTTPFailed = rb_define_class_under(mCurlErr, "HTTPFailedError", eCurlErrHTTPError); eCurlErrWriteError = rb_define_class_under(mCurlErr, "WriteError", eCurlErrError); eCurlErrMalformedUser = rb_define_class_under(mCurlErr, "MalformedUserError", eCurlErrError); eCurlErrFTPCouldntStorFile = rb_define_class_under(mCurlErr, "CouldntStorFileError", eCurlErrFTPError); eCurlErrReadError = rb_define_class_under(mCurlErr, "ReadError", eCurlErrError); eCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "OutOfMemoryError", eCurlErrError); eCurlErrTimeout = rb_define_class_under(mCurlErr, "TimeoutError", eCurlErrError); eCurlErrFTPCouldntSetASCII = rb_define_class_under(mCurlErr, "CouldntSetASCIIError", eCurlErrFTPError); eCurlErrFTPPortFailed = rb_define_class_under(mCurlErr, "PortFailedError", eCurlErrFTPError); eCurlErrFTPCouldntUseRest = rb_define_class_under(mCurlErr, "CouldntUseRestError", eCurlErrFTPError); eCurlErrFTPCouldntGetSize = rb_define_class_under(mCurlErr, "CouldntGetSizeError", eCurlErrFTPError); eCurlErrHTTPRange = rb_define_class_under(mCurlErr, "HTTPRangeError", eCurlErrHTTPError); eCurlErrHTTPPost = rb_define_class_under(mCurlErr, "HTTPPostError", eCurlErrHTTPError); eCurlErrSSLConnectError = rb_define_class_under(mCurlErr, "SSLConnectError", eCurlErrError); eCurlErrBadResume = rb_define_class_under(mCurlErr, "BadResumeError", eCurlErrError); eCurlErrFileCouldntRead = rb_define_class_under(mCurlErr, "CouldntReadError", eCurlErrFileError); eCurlErrLDAPCouldntBind = rb_define_class_under(mCurlErr, "CouldntBindError", eCurlErrLDAPError); eCurlErrLDAPSearchFailed = rb_define_class_under(mCurlErr, "SearchFailedError", eCurlErrLDAPError); eCurlErrLibraryNotFound = rb_define_class_under(mCurlErr, "LibraryNotFoundError", eCurlErrError); eCurlErrFunctionNotFound = rb_define_class_under(mCurlErr, "FunctionNotFoundError", eCurlErrError); eCurlErrAbortedByCallback = rb_define_class_under(mCurlErr, "AbortedByCallbackError", eCurlErrError); eCurlErrBadFunctionArgument = rb_define_class_under(mCurlErr, "BadFunctionArgumentError", eCurlErrError); eCurlErrBadCallingOrder = rb_define_class_under(mCurlErr, "BadCallingOrderError", eCurlErrError); eCurlErrInterfaceFailed = rb_define_class_under(mCurlErr, "InterfaceFailedError", eCurlErrError); eCurlErrBadPasswordEntered = rb_define_class_under(mCurlErr, "BadPasswordEnteredError", eCurlErrError); eCurlErrTooManyRedirects = rb_define_class_under(mCurlErr, "TooManyRedirectsError", eCurlErrError); eCurlErrTelnetUnknownOption = rb_define_class_under(mCurlErr, "UnknownOptionError", eCurlErrTelnetError); eCurlErrTelnetBadOptionSyntax = rb_define_class_under(mCurlErr, "BadOptionSyntaxError", eCurlErrTelnetError); eCurlErrObsolete = rb_define_class_under(mCurlErr, "ObsoleteError", eCurlErrError); eCurlErrSSLPeerCertificate = rb_define_class_under(mCurlErr, "SSLPeerCertificateError", eCurlErrError); eCurlErrGotNothing = rb_define_class_under(mCurlErr, "GotNothingError", eCurlErrError); eCurlErrSSLEngineNotFound = rb_define_class_under(mCurlErr, "SSLEngineNotFoundError", eCurlErrError); eCurlErrSSLEngineSetFailed = rb_define_class_under(mCurlErr, "SSLEngineSetFailedError", eCurlErrError); eCurlErrSendError = rb_define_class_under(mCurlErr, "SendError", eCurlErrError); eCurlErrRecvError = rb_define_class_under(mCurlErr, "RecvError", eCurlErrError); eCurlErrShareInUse = rb_define_class_under(mCurlErr, "ShareInUseError", eCurlErrError); eCurlErrSSLCertificate = rb_define_class_under(mCurlErr, "SSLCertificateError", eCurlErrError); eCurlErrSSLCipher = rb_define_class_under(mCurlErr, "SSLCypherError", eCurlErrError); eCurlErrSSLCACertificate = rb_define_class_under(mCurlErr, "SSLCACertificateError", eCurlErrError); eCurlErrBadContentEncoding = rb_define_class_under(mCurlErr, "BadContentEncodingError", eCurlErrError); eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError); eCurlErrFileSizeExceeded = rb_define_class_under(mCurlErr, "FileSizeExceededError", eCurlErrError); eCurlErrFTPSSLFailed = rb_define_class_under(mCurlErr, "FTPSSLFailed", eCurlErrFTPError); eCurlErrSendFailedRewind = rb_define_class_under(mCurlErr, "SendFailedRewind", eCurlErrError); eCurlErrSSLEngineInitFailed = rb_define_class_under(mCurlErr, "SSLEngineInitFailedError", eCurlErrError); eCurlErrLoginDenied = rb_define_class_under(mCurlErr, "LoginDeniedError", eCurlErrError); eCurlErrTFTPNotFound = rb_define_class_under(mCurlErr, "NotFoundError", eCurlErrTFTPError); eCurlErrTFTPPermission = rb_define_class_under(mCurlErr, "PermissionError", eCurlErrTFTPError); eCurlErrTFTPDiskFull = rb_define_class_under(mCurlErr, "DiskFullError", eCurlErrTFTPError); eCurlErrTFTPIllegalOperation = rb_define_class_under(mCurlErr, "IllegalOperationError", eCurlErrTFTPError); eCurlErrTFTPUnknownID = rb_define_class_under(mCurlErr, "UnknownIDError", eCurlErrTFTPError); eCurlErrTFTPFileExists = rb_define_class_under(mCurlErr, "FileExistsError", eCurlErrTFTPError); eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError); eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError); }
DECKLSPECKL void Init_RUDL() { DEBUG_S("Init_RUDL()"); moduleRUDL=rb_define_module("RUDL"); rb_define_singleton_method(moduleRUDL, "at_exit", RUDL_at_exit, 0); rb_define_singleton_method(moduleRUDL, "init_subsystem", RUDL_init, 1); rb_define_singleton_method(moduleRUDL, "quit_subsystem", RUDL_quit, 1); rb_define_singleton_method(moduleRUDL, "is_subsystem_init", RUDL_is_init, 1); rb_define_singleton_method(moduleRUDL, "versions", RUDL_versions, 0); /** @class RUDL::SDLError SDLError is the class that is thrown when SDL or RUDL find an SDL-specific problem. */ classSDLError=rb_define_class("SDLError", rb_eStandardError); /** @class RUDL::Pit The @Pit is where the things end up that don't fit anywhere else. The methods are documented where they fit best. */ classPit=rb_define_class_under(moduleRUDL, "Pit", rb_cObject); /** @class RUDL::Version @Version is the class used for version comparisons. It defines four version levels: major, minor, patch and deepest. */ /** @method initialize( major=0, minor=0, patch=0, deepest=0 ) Initializes a new Version object. */ /** @method <( v ) Compares this version number with the one in @v. Returns <code>true</code> if older. */ /** @method to_s Returns the version as a string: "major.minor.patch.deepest" */ rb_eval_string( "module RUDL\n" " class Version\n" " attr_accessor :major, :minor, :patch, :deepest\n" " def <(v)\n" " (@major<v.major) or\n" " (@major==v.major and @minor<v.minor) or\n" " (@major==v.major and @minor==v.minor and @patch<v.patch) or\n" " (@major==v.major and @minor==v.minor and @patch==v.patch and @deepest<v.deepest)\n" " end\n" " def initialize(major=0, minor=0, patch=0, deepest=0)\n" " @major=major\n" " @minor=minor\n" " @patch=patch\n" " @deepest=deepest\n" " end\n" " def to_s\n" " \"#{major}.#{minor}.#{patch}.#{deepest}\"\n" " end\n" " end\n" "end\n" ); id_begin=rb_intern("begin"); id_end=rb_intern("end"); id_new=rb_intern("new"); id_clone=rb_intern("clone"); /** @class RUDL::Constants All for the hacked @init_subsystem and @quit_subsystem, which should officially never be needed: <code>INIT_TIMER, INIT_AUDIO, INIT_VIDEO, INIT_CDROM, INIT_JOYSTICK, INIT_NOPARACHUTE, INIT_EVERYTHING</code> */ moduleConstant=rb_define_module_under(moduleRUDL, "Constant"); DEC_CONST(INIT_TIMER); DEC_CONST(INIT_AUDIO); DEC_CONST(INIT_VIDEO); DEC_CONST(INIT_CDROM); DEC_CONST(INIT_JOYSTICK); DEC_CONST(INIT_NOPARACHUTE); DEC_CONST(INIT_EVERYTHING); initAudioClasses(); initCDClasses(); initEventsClasses(); initTrueTypeFontClasses(); initJoystickClasses(); initKeyClasses(); initMouseClasses(); initTimerClasses(); initVideoClasses(); initSFontClasses(); initFLXClasses(); initNetClasses(); initSDL();
void Init_dataerror(VALUE klass) { VALUE rb_eDataErr = rb_define_class_under(klass, "DataError", rb_eStandardError); rb_define_alloc_func(rb_eDataErr, dataerror_alloc); }
void Init_ool(VALUE module) { VALUE mOOL, mConmin; VALUE cool_conmin_minimizer; mOOL = rb_define_module("OOL"); mConmin = rb_define_module_under(mOOL, "Conmin"); cool_conmin_function = rb_define_class_under(mConmin, "Function", cgsl_function); cool_conmin_constraint = rb_define_class_under(mConmin, "Constraint", cGSL_Object); cool_conmin_minimizer = rb_define_class_under(mConmin, "Minimizer", cGSL_Object); cool_conmin_pgrad = rb_define_class_under(cool_conmin_minimizer, "Pgrad", cGSL_Object); cool_conmin_spg = rb_define_class_under(cool_conmin_minimizer, "Spg", cGSL_Object); cool_conmin_gencan = rb_define_class_under(cool_conmin_minimizer, "Gencan", cGSL_Object); def_const(mOOL); rb_define_singleton_method(cool_conmin_minimizer, "alloc", rb_ool_conmin_minimizer_alloc, -1); rb_define_method(cool_conmin_minimizer, "set", rb_ool_conmin_minimizer_set, -1); rb_define_method(cool_conmin_minimizer, "parameters_default", rb_ool_conmin_minimizer_parameters_default, 0); rb_define_method(cool_conmin_minimizer, "name", rb_ool_conmin_minimizer_name, 0); rb_define_method(cool_conmin_minimizer, "size", rb_ool_conmin_minimizer_size, 0); rb_define_method(cool_conmin_minimizer, "f", rb_ool_conmin_minimizer_f, 0); rb_define_method(cool_conmin_minimizer, "x", rb_ool_conmin_minimizer_x, 0); rb_define_method(cool_conmin_minimizer, "dx", rb_ool_conmin_minimizer_dx, 0); rb_define_method(cool_conmin_minimizer, "gradient", rb_ool_conmin_minimizer_gradient, 0); rb_define_method(cool_conmin_minimizer, "minimum", rb_ool_conmin_minimizer_minimum, 0); rb_define_method(cool_conmin_minimizer, "fcount", rb_ool_conmin_minimizer_fcount, 0); rb_define_method(cool_conmin_minimizer, "gcount", rb_ool_conmin_minimizer_gcount, 0); rb_define_method(cool_conmin_minimizer, "hcount", rb_ool_conmin_minimizer_hcount, 0); rb_define_method(cool_conmin_minimizer, "is_optimal", rb_ool_conmin_minimizer_is_optimal, 0); rb_define_method(cool_conmin_minimizer, "is_optimal?", rb_ool_conmin_minimizer_is_optimal2, 0); rb_define_method(cool_conmin_minimizer, "iterate", rb_ool_conmin_minimizer_iterate, 0); rb_define_method(cool_conmin_minimizer, "restart", rb_ool_conmin_minimizer_restart, 0); rb_define_method(cool_conmin_minimizer, "parameters_get", rb_ool_conmin_minimizer_parameters_get, 0); rb_define_method(cool_conmin_minimizer, "parameters_set", rb_ool_conmin_minimizer_parameters_set, 1); rb_define_singleton_method(cool_conmin_function, "alloc", rb_ool_conmin_function_alloc, -1); rb_define_method(cool_conmin_function, "set", rb_ool_conmin_function_set, -1); rb_define_method(cool_conmin_function, "set_n", rb_ool_conmin_function_set_n, 1); rb_define_alias(cool_conmin_function, "n=", "set_n"); rb_define_method(cool_conmin_function, "n", rb_ool_conmin_function_n, 0); rb_define_method(cool_conmin_function, "params", rb_ool_conmin_function_params, 0); rb_define_method(cool_conmin_function, "set_params", rb_ool_conmin_function_set_params, 1); rb_define_alias(cool_conmin_function, "params=", "set_params"); rb_define_method(cool_conmin_function, "set_functions", rb_ool_conmin_function_set_functions, 1); rb_define_alias(cool_conmin_function, "functions=", "set_functions"); rb_define_method(cool_conmin_function, "set_f", rb_ool_conmin_function_set_f, 1); rb_define_alias(cool_conmin_function, "f=", "set_f"); rb_define_method(cool_conmin_function, "set_df", rb_ool_conmin_function_set_df, 1); rb_define_alias(cool_conmin_function, "df=", "set_df"); rb_define_method(cool_conmin_function, "set_fdf", rb_ool_conmin_function_set_fdf, 1); rb_define_alias(cool_conmin_function, "fdf=", "set_fdf"); rb_define_method(cool_conmin_function, "set_Hv", rb_ool_conmin_function_set_Hv, 1); rb_define_alias(cool_conmin_function, "Hv=", "set_Hv"); rb_define_singleton_method(cool_conmin_constraint, "alloc", rb_ool_conmin_constraint_alloc, -1); rb_define_method(cool_conmin_constraint, "set", rb_ool_conmin_constraint_set, -1); rb_define_method(cool_conmin_constraint, "set_n", rb_ool_conmin_constraint_set_n, 1); rb_define_alias(cool_conmin_constraint, "n=", "set_n"); rb_define_method(cool_conmin_constraint, "set_L", rb_ool_conmin_constraint_set_L, 1); rb_define_alias(cool_conmin_constraint, "L=", "set_L"); rb_define_method(cool_conmin_constraint, "set_U", rb_ool_conmin_constraint_set_U, 1); rb_define_alias(cool_conmin_constraint, "U=", "set_U"); rb_define_method(cool_conmin_constraint, "set_LU", rb_ool_conmin_constraint_set_LU, 2); rb_define_alias(cool_conmin_constraint, "LU=", "set_LU"); cool_conmin_pgrad_parameters = rb_define_class_under(cool_conmin_pgrad, "Parameters", rb_cArray); cool_conmin_spg_parameters = rb_define_class_under(cool_conmin_spg, "Parameters", rb_cArray); cool_conmin_gencan_parameters = rb_define_class_under(cool_conmin_gencan, "Parameters", rb_cArray); rb_define_singleton_method(cool_conmin_pgrad, "parameters_default", rb_ool_conmin_pgrad_parameters_default, 0); rb_define_singleton_method(cool_conmin_spg, "parameters_default", rb_ool_conmin_spg_parameters_default, 0); rb_define_singleton_method(cool_conmin_gencan, "parameters_default", rb_ool_conmin_gencan_parameters_default, 0); }