コード例 #1
0
ファイル: digest.c プロジェクト: genki/ruby
void
Init_digest(void)
{
    id_reset           = rb_intern("reset");
    id_update          = rb_intern("update");
    id_finish          = rb_intern("finish");
    id_digest          = rb_intern("digest");
    id_hexdigest       = rb_intern("hexdigest");
    id_digest_length   = rb_intern("digest_length");

    /*
     * module Digest
     */
    rb_mDigest = rb_define_module("Digest");

    /* module functions */
    rb_define_module_function(rb_mDigest, "hexencode", rb_digest_s_hexencode, 1);

    /*
     * module Digest::Instance
     */
    rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance");

    /* instance methods that should be overridden */
    rb_define_method(rb_mDigest_Instance, "update", rb_digest_instance_update, 1);
    rb_define_method(rb_mDigest_Instance, "<<", rb_digest_instance_update, 1);
    rb_define_private_method(rb_mDigest_Instance, "finish", rb_digest_instance_finish, 0);
    rb_define_method(rb_mDigest_Instance, "reset", rb_digest_instance_reset, 0);
    rb_define_method(rb_mDigest_Instance, "digest_length", rb_digest_instance_digest_length, 0);
    rb_define_method(rb_mDigest_Instance, "block_length", rb_digest_instance_block_length, 0);

    /* instance methods that may be overridden */
    rb_define_method(rb_mDigest_Instance, "==", rb_digest_instance_equal, 1);
    rb_define_method(rb_mDigest_Instance, "inspect", rb_digest_instance_inspect, 0);

    /* instance methods that need not usually be overridden */
    rb_define_method(rb_mDigest_Instance, "new", rb_digest_instance_new, 0);
    rb_define_method(rb_mDigest_Instance, "digest", rb_digest_instance_digest, -1);
    rb_define_method(rb_mDigest_Instance, "digest!", rb_digest_instance_digest_bang, 0);
    rb_define_method(rb_mDigest_Instance, "hexdigest", rb_digest_instance_hexdigest, -1);
    rb_define_method(rb_mDigest_Instance, "hexdigest!", rb_digest_instance_hexdigest_bang, 0);
    rb_define_method(rb_mDigest_Instance, "to_s", rb_digest_instance_to_s, 0);
    rb_define_method(rb_mDigest_Instance, "length", rb_digest_instance_length, 0);
    rb_define_method(rb_mDigest_Instance, "size", rb_digest_instance_length, 0);

    /*
     * class Digest::Class
     */
    rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject);
    rb_include_module(rb_cDigest_Class, rb_mDigest_Instance);

    /* class methods */
    rb_define_singleton_method(rb_cDigest_Class, "digest", rb_digest_class_s_digest, -1);
    rb_define_singleton_method(rb_cDigest_Class, "hexdigest", rb_digest_class_s_hexdigest, -1);

    id_metadata = rb_intern("metadata");

    /* class Digest::Base < Digest::Class */
    rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class);

    rb_define_alloc_func(rb_cDigest_Base, rb_digest_base_alloc);

    rb_define_method(rb_cDigest_Base, "initialize_copy",  rb_digest_base_copy, 1);
    rb_define_method(rb_cDigest_Base, "reset", rb_digest_base_reset, 0);
    rb_define_method(rb_cDigest_Base, "update", rb_digest_base_update, 1);
    rb_define_method(rb_cDigest_Base, "<<", rb_digest_base_update, 1);
    rb_define_private_method(rb_cDigest_Base, "finish", rb_digest_base_finish, 0);
    rb_define_method(rb_cDigest_Base, "digest_length", rb_digest_base_digest_length, 0);
    rb_define_method(rb_cDigest_Base, "block_length", rb_digest_base_block_length, 0);
}
コード例 #2
0
ファイル: etc.c プロジェクト: Danylyuk/first_app
/*
 * The Etc module provides access to information typically stored in
 * files in the /etc directory on Unix systems.
 *
 * The information accessible consists of the information found in the
 * /etc/passwd and /etc/group files, plus information about the system's
 * temporary directory (/tmp) and configuration directory (/etc).
 *
 * The Etc module provides a more reliable way to access information about
 * the logged in user than environment variables such as +$USER+.
 *
 * == Example:
 *
 *     require 'etc'
 *
 *     login = Etc.getlogin
 *     info = Etc.getpwnam(login)
 *     username = info.gecos.split(/,/).first
 *     puts "Hello #{username}, I see your login name is #{login}"
 *
 * Note that the methods provided by this module are not always secure.
 * It should be used for informational purposes, and not for security.
 *
 * All operations defined in this module are class methods, so that you can
 * include the Etc module into your class.
 */
void
Init_etc(void)
{
    VALUE mEtc;

    mEtc = rb_define_module("Etc");
    rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);

    rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
    rb_define_module_function(mEtc, "getpwnam", etc_getpwnam, 1);
    rb_define_module_function(mEtc, "setpwent", etc_setpwent, 0);
    rb_define_module_function(mEtc, "endpwent", etc_endpwent, 0);
    rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
    rb_define_module_function(mEtc, "passwd", etc_passwd, 0);

    rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, -1);
    rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
    rb_define_module_function(mEtc, "group", etc_group, 0);
    rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
    rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
    rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
    rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0);
    rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);

    sPasswd =  rb_struct_define_under(mEtc, "Passwd",
				      "name",
#ifdef HAVE_STRUCT_PASSWD_PW_PASSWD
				      "passwd",
#endif
				      "uid",
				      "gid",
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
				      "gecos",
#endif
				      "dir",
				      "shell",
#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
				      "change",
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
				      "quota",
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_AGE
				      "age",
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
				      "uclass",
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_COMMENT
				      "comment",
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
				      "expire",
#endif
				      NULL);
#if 0
    /* Define-const: Passwd
     *
     * Passwd is a Struct that contains the following members:
     *
     * name::
     *	    contains the short login name of the user as a String.
     * passwd::
     *	    contains the encrypted password of the user as a String.
     *	    an 'x' is returned if shadow passwords are in use. An '*' is returned
     *      if the user cannot log in using a password.
     * uid::
     *	    contains the integer user ID (uid) of the user.
     * gid::
     *	    contains the integer group ID (gid) of the user's primary group.
     * dir::
     *	    contains the path to the home directory of the user as a String.
     * shell::
     *	    contains the path to the login shell of the user as a String.
     *
     * === The following members below are optional, and must be compiled with special flags:
     *
     * gecos::
     *     contains a longer String description of the user, such as
     *	   a full name. Some Unix systems provide structured information in the
     *     gecos field, but this is system-dependent.
     *     must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+
     * change::
     *     password change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+
     * quota::
     *     quota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+
     * age::
     *     password age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+
     * class::
     *     user access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+
     * comment::
     *     comment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+
     * expire::
     *	    account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+
     */
    rb_define_const(mEtc, "Passwd", sPasswd);
#endif
    rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
    rb_extend_object(sPasswd, rb_mEnumerable);
    rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);

#ifdef HAVE_GETGRENT
    sGroup = rb_struct_define_under(mEtc, "Group", "name",
#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
				    "passwd",
#endif
				    "gid", "mem", NULL);

#if 0
    /* Define-const: Group
     *
     * Group is a Struct that is only available when compiled with +HAVE_GETGRENT+.
     *
     * The struct contains the following members:
     *
     * name::
     *	    contains the name of the group as a String.
     * passwd::
     *	    contains the encrypted password as a String. An 'x' is
     *	    returned if password access to the group is not available; an empty
     *	    string is returned if no password is needed to obtain membership of
     *	    the group.
     *
     *	    Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+.
     * gid::
     *	    contains the group's numeric ID as an integer.
     * mem::
     *	    is an Array of Strings containing the short login names of the
     *	    members of the group.
     */
    rb_define_const(mEtc, "Group", sGroup);
#endif
    rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */
    rb_extend_object(sGroup, rb_mEnumerable);
    rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
#endif
}
コード例 #3
0
ファイル: Fcs3Aux.c プロジェクト: mountetna/germ
void Init_fcs3_aux() {
	Fcs3Aux = rb_define_module("Fcs3Aux");
	rb_define_method(Fcs3Aux, "read_fcs_header", method_read_fcs_header, 0);
	rb_define_method(Fcs3Aux, "get_text", method_get_text, 0);
	rb_define_method(Fcs3Aux, "get_data", method_get_data, 0);
}
コード例 #4
0
ファイル: ossl.c プロジェクト: ayumin/ruby
/*
 * 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::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 ecryption 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
 *
 * Documents encrypted with the public key can only be decrypted with the
 * private key.
 *
 *   public_encrypted = key.public_encrypt 'top secret document'
 *
 * Documents encrypted with the private key can only be decrypted with the
 * public key.
 *
 *   private_encrypted = key.private_encrypt 'public release document'
 *
 * === Decryption
 *
 * Use the opposite key type do decrypt the document
 *
 *   top_secret = key.public_decrypt public_encrypted
 *
 *   public_release = key.private_decrypt private_encrypted
 *
 * == 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.
 *
 * 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::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::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
 *
 *   extension_factory.create_extension 'basicConstraints', 'CA:FALSE'
 *   extension_factory.create_extension 'keyUsage',
 *     'keyEncipherment,dataEncipherment,digitalSignature'
 *   extension_factory.create_extension 'subjectKeyIdentifier', 'hash'
 *
 * === 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
 *
 *   extension_factory.create_extension 'subjectKeyIdentifier', 'hash'
 *
 * This extension indicates the CA's key may be used as a CA.
 *
 *   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.
 *
 *   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
 *
 *   extension_factory.create_extension 'basicConstraints', 'CA:FALSE'
 *   extension_factory.create_extension 'keyUsage',
 *     'keyEncipherment,dataEncipherment,digitalSignature'
 *   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));

    /*
     * 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();
}
コード例 #5
0
ファイル: error.c プロジェクト: RWB01/Code-Translator
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);
}
コード例 #6
0
ファイル: rbrsvg.c プロジェクト: benolee/ruby-gnome2
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);
}
コード例 #7
0
ファイル: svd.c プロジェクト: ryana/Ruby-SVD
void Init_svd()
{
	VALUE module = rb_define_module("SVD");
	rb_define_module_function(module, "decompose", decompose, 3);
}		
コード例 #8
0
ファイル: allegro4r.c プロジェクト: Fryguy/allegro4r
void Init_allegro4r()
{
  CALL_ID = rb_intern("call");

  mAllegro4r = rb_define_module("Allegro4r");
  mAllegro4r_API = rb_define_module_under(mAllegro4r, "API");

  cAPI_BITMAP = rb_define_class_under(mAllegro4r_API, "BITMAP", rb_cObject); // in a4r_API_BITMAP.c
  rb_define_method(cAPI_BITMAP, "h", a4r_API_BITMAP_h_get, 0); // in a4r_API_BITMAP.c
  rb_define_method(cAPI_BITMAP, "w", a4r_API_BITMAP_w_get, 0); // in a4r_API_BITMAP.c

  cAPI_JOYSTICK_INFO = rb_define_class_under(mAllegro4r_API, "JOYSTICK_INFO", rb_cObject); // in a4r_API_JOYSTICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_INFO, "flags", a4r_API_JOYSTICK_INFO_flags, 0); // in a4r_API_JOYSTICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_INFO, "num_sticks", a4r_API_JOYSTICK_INFO_num_sticks, 0); // in a4r_API_JOYSTICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_INFO, "num_buttons", a4r_API_JOYSTICK_INFO_num_buttons, 0); // in a4r_API_JOYSTICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_INFO, "stick", a4r_API_JOYSTICK_INFO_stick, 0); // in a4r_API_JOYSTICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_INFO, "button", a4r_API_JOYSTICK_INFO_button, 0); // in a4r_API_JOYSTICK_INFO.c

  cAPI_JOYSTICK_BUTTON_INFO = rb_define_class_under(mAllegro4r_API, "JOYSTICK_BUTTON_INFO", rb_cObject); // in a4r_API_JOYSTICK_BUTTON_INFO.c
  rb_define_method(cAPI_JOYSTICK_BUTTON_INFO, "b", a4r_API_JOYSTICK_BUTTON_INFO_b, 0); // in a4r_API_JOYSTICK_BUTTON_INFO.c
  rb_define_method(cAPI_JOYSTICK_BUTTON_INFO, "name", a4r_API_JOYSTICK_BUTTON_INFO_name, 0); // in a4r_API_JOYSTICK_BUTTON_INFO.c

  cAPI_JOYSTICK_STICK_INFO = rb_define_class_under(mAllegro4r_API, "JOYSTICK_STICK_INFO", rb_cObject); // in a4r_API_JOYSTICK_STICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_STICK_INFO, "flags", a4r_API_JOYSTICK_STICK_INFO_flags, 0); // in a4r_API_JOYSTICK_STICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_STICK_INFO, "num_axis", a4r_API_JOYSTICK_STICK_INFO_num_axis, 0); // in a4r_API_JOYSTICK_STICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_STICK_INFO, "axis", a4r_API_JOYSTICK_STICK_INFO_axis, 0); // in a4r_API_JOYSTICK_STICK_INFO.c
  rb_define_method(cAPI_JOYSTICK_STICK_INFO, "name", a4r_API_JOYSTICK_STICK_INFO_name, 0); // in a4r_API_JOYSTICK_STICK_INFO.c

  cAPI_JOYSTICK_AXIS_INFO = rb_define_class_under(mAllegro4r_API, "JOYSTICK_AXIS_INFO", rb_cObject); // in a4r_API_JOYSTICK_AXIS_INFO.c
  rb_define_method(cAPI_JOYSTICK_AXIS_INFO, "pos", a4r_API_JOYSTICK_AXIS_INFO_pos, 0); // in a4r_API_JOYSTICK_AXIS_INFO.c
  rb_define_method(cAPI_JOYSTICK_AXIS_INFO, "d1", a4r_API_JOYSTICK_AXIS_INFO_d1, 0); // in a4r_API_JOYSTICK_AXIS_INFO.c
  rb_define_method(cAPI_JOYSTICK_AXIS_INFO, "d2", a4r_API_JOYSTICK_AXIS_INFO_d2, 0); // in a4r_API_JOYSTICK_AXIS_INFO.c
  rb_define_method(cAPI_JOYSTICK_AXIS_INFO, "name", a4r_API_JOYSTICK_AXIS_INFO_name, 0); // in a4r_API_JOYSTICK_AXIS_INFO.c

  cAPI_PALETTE = rb_define_class_under(mAllegro4r_API, "PALETTE", rb_cObject); // in a4r_API_PALETTE.c
  rb_define_alloc_func(cAPI_PALETTE, a4r_API_PALETTE_alloc); // in a4r_API_PALETTE.c
  rb_define_method(cAPI_PALETTE, "initialize_copy", a4r_API_PALETTE_initialize_copy, 1); // in a4r_API_PALETTE.c
  rb_define_method(cAPI_PALETTE, "[]", a4r_API_PALETTE_getter, 1); // in a4r_API_PALETTE.c
  rb_define_method(cAPI_PALETTE, "[]=", a4r_API_PALETTE_setter, 2); // in a4r_API_PALETTE.c

  cAPI_RGB = rb_define_class_under(mAllegro4r_API, "RGB", rb_cObject); // in a4r_API_RGB.c
  rb_define_alloc_func(cAPI_RGB, a4r_API_RGB_alloc); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "initialize_copy", a4r_API_RGB_initialize_copy, 1); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "r", a4r_API_RGB_r_get, 0); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "r=", a4r_API_RGB_r_set, 1); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "g", a4r_API_RGB_g_get, 0); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "g=", a4r_API_RGB_g_set, 1); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "b", a4r_API_RGB_b_get, 0); // in a4r_API_RGB.c
  rb_define_method(cAPI_RGB, "b=", a4r_API_RGB_b_set, 1); // in a4r_API_RGB.c

  cAPI_FONT = rb_define_class_under(mAllegro4r_API, "FONT", rb_cObject);

  cAPI_SAMPLE = rb_define_class_under(mAllegro4r_API, "SAMPLE", rb_cObject);

  cAPI_MIDI = rb_define_class_under(mAllegro4r_API, "MIDI", rb_cObject);

  cAPI_GFX_DRIVER = rb_define_class_under(mAllegro4r_API, "GFX_DRIVER", rb_cObject); // in a4r_API_GFX_DRIVER.c
  rb_define_method(cAPI_GFX_DRIVER, "name", a4r_API_GFX_DRIVER_name_get, 0); // in a4r_API_GFX_DRIVER.c

  cAPI_MOUSE_DRIVER = rb_define_class_under(mAllegro4r_API, "MOUSE_DRIVER", rb_cObject); // in a4r_API_MOUSE_DRIVER.c
  rb_define_method(cAPI_MOUSE_DRIVER, "name", a4r_API_MOUSE_DRIVER_name_get, 0); // in a4r_API_MOUSE_DRIVER.c

  cAPI_TIMER_DRIVER = rb_define_class_under(mAllegro4r_API, "TIMER_DRIVER", rb_cObject); // in a4r_API_TIMER_DRIVER.c
  rb_define_method(cAPI_TIMER_DRIVER, "name", a4r_API_TIMER_DRIVER_name_get, 0); // in a4r_API_TIMER_DRIVER.c

  cAPI_KEYBOARD_DRIVER = rb_define_class_under(mAllegro4r_API, "KEYBOARD_DRIVER", rb_cObject); // in a4r_API_KEYBOARD_DRIVER.c
  rb_define_method(cAPI_KEYBOARD_DRIVER, "name", a4r_API_KEYBOARD_DRIVER_name_get, 0); // in a4r_API_KEYBOARD_DRIVER.c

  cAPI_JOYSTICK_DRIVER = rb_define_class_under(mAllegro4r_API, "JOYSTICK_DRIVER", rb_cObject); // in a4r_API_JOYSTICK_DRIVER.c
  rb_define_method(cAPI_JOYSTICK_DRIVER, "name", a4r_API_JOYSTICK_DRIVER_name_get, 0); // in a4r_API_JOYSTICK_DRIVER.c

  cAPI_DIGI_DRIVER = rb_define_class_under(mAllegro4r_API, "DIGI_DRIVER", rb_cObject); // in a4r_API_DIGI_DRIVER.c
  rb_define_method(cAPI_DIGI_DRIVER, "name", a4r_API_DIGI_DRIVER_name_get, 0); // in a4r_API_DIGI_DRIVER.c

  cAPI_MIDI_DRIVER = rb_define_class_under(mAllegro4r_API, "MIDI_DRIVER", rb_cObject); // in a4r_API_MIDI_DRIVER.c
  rb_define_method(cAPI_MIDI_DRIVER, "name", a4r_API_MIDI_DRIVER_name_get, 0); // in a4r_API_MIDI_DRIVER.c

  rb_define_module_function(mAllegro4r_API, "MIN", a4r_API_MIN, 2); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "ABS", a4r_API_ABS, 1); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "AL_RAND", a4r_API_AL_RAND, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "gfx_driver", a4r_API_gfx_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "mouse_driver", a4r_API_mouse_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "timer_driver", a4r_API_timer_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "keyboard_driver", a4r_API_keyboard_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "joystick_driver", a4r_API_joystick_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "digi_driver", a4r_API_digi_driver, 0); // in a4r_API_misc.c
  rb_define_module_function(mAllegro4r_API, "midi_driver", a4r_API_midi_driver, 0); // in a4r_API_misc.c

  rb_define_module_function(mAllegro4r_API, "allegro_init", a4r_API_allegro_init, 0); // in a4r_API_using_allegro.c
  rb_define_module_function(mAllegro4r_API, "allegro_exit", a4r_API_allegro_exit, 0); // in a4r_API_using_allegro.c
  rb_define_module_function(mAllegro4r_API, "allegro_error", a4r_API_allegro_error, 0); // in a4r_API_using_allegro.c
  rb_define_module_function(mAllegro4r_API, "allegro_message", a4r_API_allegro_message, 1); // in a4r_API_using_allegro.c

  rb_define_module_function(mAllegro4r_API, "ustrzncpy", a4r_API_ustrzncpy, 2); // in a4r_API_unicode_routines.c
  rb_define_module_function(mAllegro4r_API, "usprintf", a4r_API_usprintf, 1); // in a4r_API_unicode_routines.c

  rb_define_module_function(mAllegro4r_API, "install_mouse", a4r_API_install_mouse, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "poll_mouse", a4r_API_poll_mouse, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "mouse_x", a4r_API_mouse_x, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "mouse_y", a4r_API_mouse_y, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "mouse_z", a4r_API_mouse_z, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "mouse_w", a4r_API_mouse_w, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "mouse_b", a4r_API_mouse_b, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "show_mouse", a4r_API_show_mouse, 1); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "get_mouse_mickeys", a4r_API_get_mouse_mickeys, 0); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "set_mouse_sprite", a4r_API_set_mouse_sprite, 1); // in a4r_API_mouse_routines.c
  rb_define_module_function(mAllegro4r_API, "set_mouse_sprite_focus", a4r_API_set_mouse_sprite_focus, 2); // in a4r_API_mouse_routines.c

  rb_define_module_function(mAllegro4r_API, "install_timer", a4r_API_install_timer, 0); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "install_int", a4r_API_install_int, 2); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "install_int_ex", a4r_API_install_int_ex, 2); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "LOCK_VARIABLE", a4r_API_LOCK_VARIABLE, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "LOCK_FUNCTION", a4r_API_LOCK_FUNCTION, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "retrace_count", a4r_API_retrace_count, 0); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "rest", a4r_API_rest, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "SECS_TO_TIMER", a4r_API_SECS_TO_TIMER, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "MSEC_TO_TIMER", a4r_API_MSEC_TO_TIMER, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "BPS_TO_TIMER", a4r_API_BPS_TO_TIMER, 1); // in a4r_API_timer_routines.c
  rb_define_module_function(mAllegro4r_API, "BPM_TO_TIMER", a4r_API_BPM_TO_TIMER, 1); // in a4r_API_timer_routines.c

  timer_counter_names = rb_hash_new();
  rb_global_variable(&timer_counter_names);
  LOCK_VARIABLE(timer_counters)
  LOCK_FUNCTION(timer_counter_incr)
  rb_define_module_function(mAllegro4r_API, "timer_counter_get", a4r_API_timer_counter_get, 1); // in a4r_API_timer_routines.c

  rb_define_module_function(mAllegro4r_API, "install_keyboard", a4r_API_install_keyboard, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "poll_keyboard", a4r_API_poll_keyboard, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "key", a4r_API_key, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "key_shifts", a4r_API_key_shifts, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "keypressed", a4r_API_keypressed, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "readkey", a4r_API_readkey, 0); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "ureadkey", a4r_API_ureadkey, 1); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "scancode_to_name", a4r_API_scancode_to_name, 1); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "keyboard_callback=", a4r_API_keyboard_callback_set, 1); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "keyboard_lowlevel_callback=", a4r_API_keyboard_lowlevel_callback_set, 1); // in a4r_API_keyboard_routines.c
  rb_define_module_function(mAllegro4r_API, "clear_keybuf", a4r_API_clear_keybuf, 0); // in a4r_API_keyboard_routines.c

  rb_global_variable(&keyboard_callback_proc);
  rb_global_variable(&keyboard_lowlevel_callback_proc);
  LOCK_VARIABLE(keyboard_callback_proc)
  LOCK_VARIABLE(keyboard_lowlevel_callback_proc)
  LOCK_FUNCTION(keyboard_callback_method)
  LOCK_FUNCTION(keyboard_lowlevel_callback_method)

  rb_define_module_function(mAllegro4r_API, "install_joystick", a4r_API_install_joystick, 1); // in a4r_API_joystick_routines.c
  rb_define_module_function(mAllegro4r_API, "poll_joystick", a4r_API_poll_joystick, 0); // in a4r_API_joystick_routines.c
  rb_define_module_function(mAllegro4r_API, "num_joysticks", a4r_API_num_joysticks, 0); // in a4r_API_joystick_routines.c
  rb_define_module_function(mAllegro4r_API, "joy", a4r_API_joy, 0); // in a4r_API_joystick_routines.c
  rb_define_module_function(mAllegro4r_API, "calibrate_joystick_name", a4r_API_calibrate_joystick_name, 1); // in a4r_API_joystick_routines.c
  rb_define_module_function(mAllegro4r_API, "calibrate_joystick", a4r_API_calibrate_joystick, 1); // in a4r_API_joystick_routines.c

  rb_define_module_function(mAllegro4r_API, "set_gfx_mode", a4r_API_set_gfx_mode, 5); // in a4r_API_graphics_modes.c
  rb_define_module_function(mAllegro4r_API, "set_display_switch_mode", a4r_API_set_display_switch_mode, 1); // in a4r_API_graphics_modes.c
  rb_define_module_function(mAllegro4r_API, "show_video_bitmap", a4r_API_show_video_bitmap, 1); // in a4r_API_graphics_modes.c
  rb_define_module_function(mAllegro4r_API, "vsync", a4r_API_vsync, 0); // in a4r_API_graphics_modes.c

  rb_define_module_function(mAllegro4r_API, "screen", a4r_API_screen, 0); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "SCREEN_W", a4r_API_SCREEN_W, 0); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "SCREEN_H", a4r_API_SCREEN_H, 0); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "create_bitmap", a4r_API_create_bitmap, 2); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "create_sub_bitmap", a4r_API_create_sub_bitmap, 5); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "create_video_bitmap", a4r_API_create_video_bitmap, 2); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "destroy_bitmap", a4r_API_destroy_bitmap, 1); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "bitmap_mask_color", a4r_API_bitmap_mask_color, 1); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "acquire_bitmap", a4r_API_acquire_bitmap, 1); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "release_bitmap", a4r_API_release_bitmap, 1); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "acquire_screen", a4r_API_acquire_screen, 0); // in a4r_API_bitmap_objects.c
  rb_define_module_function(mAllegro4r_API, "release_screen", a4r_API_release_screen, 0); // in a4r_API_bitmap_objects.c

  rb_define_module_function(mAllegro4r_API, "set_palette", a4r_API_set_palette, 1); // in a4r_API_palette_routines.c
  rb_define_module_function(mAllegro4r_API, "get_palette", a4r_API_get_palette, 1); // in a4r_API_palette_routines.c
  rb_define_module_function(mAllegro4r_API, "default_palette", a4r_API_default_palette, 0); // in a4r_API_palette_routines.c
  rb_define_module_function(mAllegro4r_API, "black_palette", a4r_API_black_palette, 0); // in a4r_API_palette_routines.c
  rb_define_module_function(mAllegro4r_API, "desktop_palette", a4r_API_desktop_palette, 0); // in a4r_API_palette_routines.c

  rb_define_module_function(mAllegro4r_API, "makecol", a4r_API_makecol, 3); // in a4r_API_truecolor_pixel_formats.c
  rb_define_module_function(mAllegro4r_API, "palette_color", a4r_API_palette_color, 0); // in a4r_API_truecolor_pixel_formats.c

  rb_define_module_function(mAllegro4r_API, "clear_bitmap", a4r_API_clear_bitmap, 1); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "clear_to_color", a4r_API_clear_to_color, 2); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "putpixel", a4r_API_putpixel, 4); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "getpixel", a4r_API_getpixel, 3); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "rectfill", a4r_API_rectfill, 6); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "circle", a4r_API_circle, 5); // in a4r_API_drawing_primitives.c
  rb_define_module_function(mAllegro4r_API, "circlefill", a4r_API_circlefill, 5); // in a4r_API_drawing_primitives.c

  rb_define_module_function(mAllegro4r_API, "blit", a4r_API_blit, 8); // in a4r_API_blitting_and_sprites.c
  rb_define_module_function(mAllegro4r_API, "masked_blit", a4r_API_masked_blit, 8); // in a4r_API_blitting_and_sprites.c

  rb_define_module_function(mAllegro4r_API, "load_font", a4r_API_load_font, 3); // in a4r_API_fonts.c
  rb_define_module_function(mAllegro4r_API, "destroy_font", a4r_API_destroy_font, 1); // in a4r_API_fonts.c
  rb_define_module_function(mAllegro4r_API, "extract_font_range", a4r_API_extract_font_range, 3); // in a4r_API_fonts.c
  rb_define_module_function(mAllegro4r_API, "merge_fonts", a4r_API_merge_fonts, 2); // in a4r_API_fonts.c

  rb_define_module_function(mAllegro4r_API, "font", a4r_API_font, 0); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "font=", a4r_API_font_set, 1); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "text_length", a4r_API_text_length, 2); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "text_height", a4r_API_text_height, 1); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "textout_ex", a4r_API_textout_ex, 7); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "textout_centre_ex", a4r_API_textout_centre_ex, 7); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "textprintf_ex", a4r_API_textprintf_ex, 7); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "textprintf_centre_ex", a4r_API_textprintf_centre_ex, 7); // in a4r_API_text_output.c
  rb_define_module_function(mAllegro4r_API, "textprintf_right_ex", a4r_API_textprintf_right_ex, 7); // in a4r_API_text_output.c

  rb_define_module_function(mAllegro4r_API, "drawing_mode", a4r_API_drawing_mode, 4); // in a4r_API_transparency_and_patterned_drawing.c
  rb_define_module_function(mAllegro4r_API, "solid_mode", a4r_API_solid_mode, 0); // in a4r_API_transparency_and_patterned_drawing.c

  rb_define_module_function(mAllegro4r_API, "bmp_select", a4r_API_bmp_select, 1); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_read8", a4r_API_bmp_read8, 1); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_read32", a4r_API_bmp_read32, 1); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_write8", a4r_API_bmp_write8, 2); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_write32", a4r_API_bmp_write32, 2); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_write_line", a4r_API_bmp_write_line, 2); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_read_line", a4r_API_bmp_read_line, 2); // in a4r_API_direct_access_to_video_memory.c
  rb_define_module_function(mAllegro4r_API, "bmp_unwrite_line", a4r_API_bmp_unwrite_line, 1); // in a4r_API_direct_access_to_video_memory.c

  rb_define_module_function(mAllegro4r_API, "install_sound", a4r_API_install_sound, 3); // in a4r_API_sound_init_routines.c

  rb_define_module_function(mAllegro4r_API, "load_sample", a4r_API_load_sample, 1); // in a4r_API_digital_sample_routines.c
  rb_define_module_function(mAllegro4r_API, "destroy_sample", a4r_API_destroy_sample, 1); // in a4r_API_digital_sample_routines.c
  rb_define_module_function(mAllegro4r_API, "play_sample", a4r_API_play_sample, 5); // in a4r_API_digital_sample_routines.c
  rb_define_module_function(mAllegro4r_API, "adjust_sample", a4r_API_adjust_sample, 5); // in a4r_API_digital_sample_routines.c

  rb_define_module_function(mAllegro4r_API, "load_midi", a4r_API_load_midi, 1); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "destroy_midi", a4r_API_destroy_midi, 1); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "play_midi", a4r_API_play_midi, 2); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "midi_pause", a4r_API_midi_pause, 0); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "midi_resume", a4r_API_midi_resume, 0); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "get_midi_length", a4r_API_get_midi_length, 1); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "midi_pos", a4r_API_midi_pos, 0); // in a4r_API_music_routines_midi.c
  rb_define_module_function(mAllegro4r_API, "midi_time", a4r_API_midi_time, 0); // in a4r_API_music_routines_midi.c

  rb_define_module_function(mAllegro4r_API, "get_filename", a4r_API_get_filename, 1); // in a4r_API_file_and_compression_routines.c

  rb_define_module_function(mAllegro4r_API, "itofix", a4r_API_itofix, 1); // in a4r_API_fixed_point_math_routines.c
  rb_define_module_function(mAllegro4r_API, "ftofix", a4r_API_ftofix, 1); // in a4r_API_fixed_point_math_routines.c
  rb_define_module_function(mAllegro4r_API, "fixtof", a4r_API_fixtof, 1); // in a4r_API_fixed_point_math_routines.c
  rb_define_module_function(mAllegro4r_API, "fixmul", a4r_API_fixmul, 2); // in a4r_API_fixed_point_math_routines.c
  rb_define_module_function(mAllegro4r_API, "fixsqrt", a4r_API_fixsqrt, 1); // in a4r_API_fixed_point_math_routines.c

  /*
   * GFX_AUTODETECT: Allegro will try to set the specified resolution with the
   * current color depth in fullscreen mode. Failing that, it will try to repeat
   * the same operation in windowed mode.
   */
  rb_define_const(mAllegro4r_API, "GFX_AUTODETECT", INT2FIX(GFX_AUTODETECT));
  /*
   * GFX_AUTODETECT_FULLSCREEN: Allegro will try to set the specified resolution
   * with the current color depth in fullscreen mode.
   */
  rb_define_const(mAllegro4r_API, "GFX_AUTODETECT_FULLSCREEN", INT2FIX(GFX_AUTODETECT_FULLSCREEN));
  /*
   * GFX_AUTODETECT_WINDOWED: Allegro will try to set the specified resolution
   * with the current color depth in a windowed mode.
   */
  rb_define_const(mAllegro4r_API, "GFX_AUTODETECT_WINDOWED", INT2FIX(GFX_AUTODETECT_WINDOWED));
  /*
   * GFX_SAFE: Allegro will try to set the specified resolution. Failing that,
   * it will fall back upon whatever mode is known to be reliable on the current
   * platform. If it absolutely cannot set any graphics mode at all, there's no
   * possible video output on the machine.
   */
  rb_define_const(mAllegro4r_API, "GFX_SAFE", INT2NUM(GFX_SAFE));
  /*
   * GFX_TEXT: Closes any previously opened graphics mode, and in those
   * environments that have text modes, sets one previously used or the closest
   * match to that (usually 80x25).
   */
  rb_define_const(mAllegro4r_API, "GFX_TEXT", INT2FIX(GFX_TEXT));

  /* SWITCH_NONE: Disables switching. */
  rb_define_const(mAllegro4r_API, "SWITCH_NONE", INT2FIX(SWITCH_NONE));
  /* SWITCH_PAUSE: Pauses the program whenever it is in the background. */
  rb_define_const(mAllegro4r_API, "SWITCH_PAUSE", INT2FIX(SWITCH_PAUSE));
  /* 
   * SWITCH_AMNESIA: Like SWITCH_PAUSE, but this mode doesn't bother to remember
   * the contents of video memory, so the screen, and any video bitmaps that you
   * have created, will be erased after the user switches away and then back to
   * your program
   */
  rb_define_const(mAllegro4r_API, "SWITCH_AMNESIA", INT2FIX(SWITCH_AMNESIA));
  /* 
   * SWITCH_BACKGROUND: The program will carry on running in the background,
   * with the screen bitmap temporarily being pointed at a memory buffer for the
   * fullscreen drivers
   */
  rb_define_const(mAllegro4r_API, "SWITCH_BACKGROUND", INT2FIX(SWITCH_BACKGROUND));
  /* 
   * SWITCH_BACKAMNESIA: Like SWITCH_BACKGROUND, but this mode doesn't bother to
   * remember the contents of video memory
   */
  rb_define_const(mAllegro4r_API, "SWITCH_BACKAMNESIA", INT2FIX(SWITCH_BACKAMNESIA));

  /* DRAW_MODE_SOLID: The default, solid color drawing */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_SOLID", INT2FIX(DRAW_MODE_SOLID));
  /* DRAW_MODE_XOR: Exclusive-or drawing */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_XOR", INT2FIX(DRAW_MODE_XOR));
  /* DRAW_MODE_COPY_PATTERN: Multicolored pattern fill */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_COPY_PATTERN", INT2FIX(DRAW_MODE_COPY_PATTERN));
  /* DRAW_MODE_SOLID_PATTERN: Single color pattern fill */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_SOLID_PATTERN", INT2FIX(DRAW_MODE_SOLID_PATTERN));
  /* DRAW_MODE_MASKED_PATTERN: Masked pattern fill */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_MASKED_PATTERN", INT2FIX(DRAW_MODE_MASKED_PATTERN));
  /* DRAW_MODE_TRANS: Translucent color blending */
  rb_define_const(mAllegro4r_API, "DRAW_MODE_TRANS", INT2FIX(DRAW_MODE_TRANS));

  /* KB_SHIFT_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_SHIFT_FLAG", INT2FIX(KB_SHIFT_FLAG));
  /* KB_CTRL_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_CTRL_FLAG", INT2FIX(KB_CTRL_FLAG));
  /* KB_ALT_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_ALT_FLAG", INT2FIX(KB_ALT_FLAG));
  /* KB_LWIN_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_LWIN_FLAG", INT2FIX(KB_LWIN_FLAG));
  /* KB_RWIN_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_RWIN_FLAG", INT2FIX(KB_RWIN_FLAG));
  /* KB_MENU_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_MENU_FLAG", INT2FIX(KB_MENU_FLAG));
  /* KB_COMMAND_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_COMMAND_FLAG", INT2FIX(KB_COMMAND_FLAG));
  /* KB_SCROLOCK_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_SCROLOCK_FLAG", INT2FIX(KB_SCROLOCK_FLAG));
  /* KB_NUMLOCK_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_NUMLOCK_FLAG", INT2FIX(KB_NUMLOCK_FLAG));
  /* KB_CAPSLOCK_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_CAPSLOCK_FLAG", INT2FIX(KB_CAPSLOCK_FLAG));
  /* KB_INALTSEQ_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_INALTSEQ_FLAG", INT2FIX(KB_INALTSEQ_FLAG));
  /* KB_ACCENT1_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_ACCENT1_FLAG", INT2FIX(KB_ACCENT1_FLAG));
  /* KB_ACCENT2_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_ACCENT2_FLAG", INT2FIX(KB_ACCENT2_FLAG));
  /* KB_ACCENT3_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_ACCENT3_FLAG", INT2FIX(KB_ACCENT3_FLAG));
  /* KB_ACCENT4_FLAG: */
  rb_define_const(mAllegro4r_API, "KB_ACCENT4_FLAG", INT2FIX(KB_ACCENT4_FLAG));
  /* KEY_A: */
  rb_define_const(mAllegro4r_API, "KEY_A", INT2FIX(KEY_A));
  /* KEY_B: */
  rb_define_const(mAllegro4r_API, "KEY_B", INT2FIX(KEY_B));
  /* KEY_C: */
  rb_define_const(mAllegro4r_API, "KEY_C", INT2FIX(KEY_C));
  /* KEY_D: */
  rb_define_const(mAllegro4r_API, "KEY_D", INT2FIX(KEY_D));
  /* KEY_E: */
  rb_define_const(mAllegro4r_API, "KEY_E", INT2FIX(KEY_E));
  /* KEY_F: */
  rb_define_const(mAllegro4r_API, "KEY_F", INT2FIX(KEY_F));
  /* KEY_G: */
  rb_define_const(mAllegro4r_API, "KEY_G", INT2FIX(KEY_G));
  /* KEY_H: */
  rb_define_const(mAllegro4r_API, "KEY_H", INT2FIX(KEY_H));
  /* KEY_I: */
  rb_define_const(mAllegro4r_API, "KEY_I", INT2FIX(KEY_I));
  /* KEY_J: */
  rb_define_const(mAllegro4r_API, "KEY_J", INT2FIX(KEY_J));
  /* KEY_K: */
  rb_define_const(mAllegro4r_API, "KEY_K", INT2FIX(KEY_K));
  /* KEY_L: */
  rb_define_const(mAllegro4r_API, "KEY_L", INT2FIX(KEY_L));
  /* KEY_M: */
  rb_define_const(mAllegro4r_API, "KEY_M", INT2FIX(KEY_M));
  /* KEY_N: */
  rb_define_const(mAllegro4r_API, "KEY_N", INT2FIX(KEY_N));
  /* KEY_O: */
  rb_define_const(mAllegro4r_API, "KEY_O", INT2FIX(KEY_O));
  /* KEY_P: */
  rb_define_const(mAllegro4r_API, "KEY_P", INT2FIX(KEY_P));
  /* KEY_Q: */
  rb_define_const(mAllegro4r_API, "KEY_Q", INT2FIX(KEY_Q));
  /* KEY_R: */
  rb_define_const(mAllegro4r_API, "KEY_R", INT2FIX(KEY_R));
  /* KEY_S: */
  rb_define_const(mAllegro4r_API, "KEY_S", INT2FIX(KEY_S));
  /* KEY_T: */
  rb_define_const(mAllegro4r_API, "KEY_T", INT2FIX(KEY_T));
  /* KEY_U: */
  rb_define_const(mAllegro4r_API, "KEY_U", INT2FIX(KEY_U));
  /* KEY_V: */
  rb_define_const(mAllegro4r_API, "KEY_V", INT2FIX(KEY_V));
  /* KEY_W: */
  rb_define_const(mAllegro4r_API, "KEY_W", INT2FIX(KEY_W));
  /* KEY_X: */
  rb_define_const(mAllegro4r_API, "KEY_X", INT2FIX(KEY_X));
  /* KEY_Y: */
  rb_define_const(mAllegro4r_API, "KEY_Y", INT2FIX(KEY_Y));
  /* KEY_Z: */
  rb_define_const(mAllegro4r_API, "KEY_Z", INT2FIX(KEY_Z));
  /* KEY_0: */
  rb_define_const(mAllegro4r_API, "KEY_0", INT2FIX(KEY_0));
  /* KEY_1: */
  rb_define_const(mAllegro4r_API, "KEY_1", INT2FIX(KEY_1));
  /* KEY_2: */
  rb_define_const(mAllegro4r_API, "KEY_2", INT2FIX(KEY_2));
  /* KEY_3: */
  rb_define_const(mAllegro4r_API, "KEY_3", INT2FIX(KEY_3));
  /* KEY_4: */
  rb_define_const(mAllegro4r_API, "KEY_4", INT2FIX(KEY_4));
  /* KEY_5: */
  rb_define_const(mAllegro4r_API, "KEY_5", INT2FIX(KEY_5));
  /* KEY_6: */
  rb_define_const(mAllegro4r_API, "KEY_6", INT2FIX(KEY_6));
  /* KEY_7: */
  rb_define_const(mAllegro4r_API, "KEY_7", INT2FIX(KEY_7));
  /* KEY_8: */
  rb_define_const(mAllegro4r_API, "KEY_8", INT2FIX(KEY_8));
  /* KEY_9: */
  rb_define_const(mAllegro4r_API, "KEY_9", INT2FIX(KEY_9));
  /* KEY_0_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_0_PAD", INT2FIX(KEY_0_PAD));
  /* KEY_1_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_1_PAD", INT2FIX(KEY_1_PAD));
  /* KEY_2_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_2_PAD", INT2FIX(KEY_2_PAD));
  /* KEY_3_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_3_PAD", INT2FIX(KEY_3_PAD));
  /* KEY_4_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_4_PAD", INT2FIX(KEY_4_PAD));
  /* KEY_5_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_5_PAD", INT2FIX(KEY_5_PAD));
  /* KEY_6_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_6_PAD", INT2FIX(KEY_6_PAD));
  /* KEY_7_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_7_PAD", INT2FIX(KEY_7_PAD));
  /* KEY_8_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_8_PAD", INT2FIX(KEY_8_PAD));
  /* KEY_9_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_9_PAD", INT2FIX(KEY_9_PAD));
  /* KEY_F1: */
  rb_define_const(mAllegro4r_API, "KEY_F1", INT2FIX(KEY_F1));
  /* KEY_F2: */
  rb_define_const(mAllegro4r_API, "KEY_F2", INT2FIX(KEY_F2));
  /* KEY_F3: */
  rb_define_const(mAllegro4r_API, "KEY_F3", INT2FIX(KEY_F3));
  /* KEY_F4: */
  rb_define_const(mAllegro4r_API, "KEY_F4", INT2FIX(KEY_F4));
  /* KEY_F5: */
  rb_define_const(mAllegro4r_API, "KEY_F5", INT2FIX(KEY_F5));
  /* KEY_F6: */
  rb_define_const(mAllegro4r_API, "KEY_F6", INT2FIX(KEY_F6));
  /* KEY_F7: */
  rb_define_const(mAllegro4r_API, "KEY_F7", INT2FIX(KEY_F7));
  /* KEY_F8: */
  rb_define_const(mAllegro4r_API, "KEY_F8", INT2FIX(KEY_F8));
  /* KEY_F9: */
  rb_define_const(mAllegro4r_API, "KEY_F9", INT2FIX(KEY_F9));
  /* KEY_F10: */
  rb_define_const(mAllegro4r_API, "KEY_F10", INT2FIX(KEY_F10));
  /* KEY_F11: */
  rb_define_const(mAllegro4r_API, "KEY_F11", INT2FIX(KEY_F11));
  /* KEY_F12: */
  rb_define_const(mAllegro4r_API, "KEY_F12", INT2FIX(KEY_F12));
  /* KEY_ESC: */
  rb_define_const(mAllegro4r_API, "KEY_ESC", INT2FIX(KEY_ESC));
  /* KEY_TILDE: */
  rb_define_const(mAllegro4r_API, "KEY_TILDE", INT2FIX(KEY_TILDE));
  /* KEY_MINUS: */
  rb_define_const(mAllegro4r_API, "KEY_MINUS", INT2FIX(KEY_MINUS));
  /* KEY_EQUALS: */
  rb_define_const(mAllegro4r_API, "KEY_EQUALS", INT2FIX(KEY_EQUALS));
  /* KEY_BACKSPACE: */
  rb_define_const(mAllegro4r_API, "KEY_BACKSPACE", INT2FIX(KEY_BACKSPACE));
  /* KEY_TAB: */
  rb_define_const(mAllegro4r_API, "KEY_TAB", INT2FIX(KEY_TAB));
  /* KEY_OPENBRACE: */
  rb_define_const(mAllegro4r_API, "KEY_OPENBRACE", INT2FIX(KEY_OPENBRACE));
  /* KEY_CLOSEBRACE: */
  rb_define_const(mAllegro4r_API, "KEY_CLOSEBRACE", INT2FIX(KEY_CLOSEBRACE));
  /* KEY_ENTER: */
  rb_define_const(mAllegro4r_API, "KEY_ENTER", INT2FIX(KEY_ENTER));
  /* KEY_COLON: */
  rb_define_const(mAllegro4r_API, "KEY_COLON", INT2FIX(KEY_COLON));
  /* KEY_QUOTE: */
  rb_define_const(mAllegro4r_API, "KEY_QUOTE", INT2FIX(KEY_QUOTE));
  /* KEY_BACKSLASH: */
  rb_define_const(mAllegro4r_API, "KEY_BACKSLASH", INT2FIX(KEY_BACKSLASH));
  /* KEY_BACKSLASH2: */
  rb_define_const(mAllegro4r_API, "KEY_BACKSLASH2", INT2FIX(KEY_BACKSLASH2));
  /* KEY_COMMA: */
  rb_define_const(mAllegro4r_API, "KEY_COMMA", INT2FIX(KEY_COMMA));
  /* KEY_STOP: */
  rb_define_const(mAllegro4r_API, "KEY_STOP", INT2FIX(KEY_STOP));
  /* KEY_SLASH: */
  rb_define_const(mAllegro4r_API, "KEY_SLASH", INT2FIX(KEY_SLASH));
  /* KEY_SPACE: */
  rb_define_const(mAllegro4r_API, "KEY_SPACE", INT2FIX(KEY_SPACE));
  /* KEY_INSERT: */
  rb_define_const(mAllegro4r_API, "KEY_INSERT", INT2FIX(KEY_INSERT));
  /* KEY_DEL: */
  rb_define_const(mAllegro4r_API, "KEY_DEL", INT2FIX(KEY_DEL));
  /* KEY_HOME: */
  rb_define_const(mAllegro4r_API, "KEY_HOME", INT2FIX(KEY_HOME));
  /* KEY_END: */
  rb_define_const(mAllegro4r_API, "KEY_END", INT2FIX(KEY_END));
  /* KEY_PGUP: */
  rb_define_const(mAllegro4r_API, "KEY_PGUP", INT2FIX(KEY_PGUP));
  /* KEY_PGDN: */
  rb_define_const(mAllegro4r_API, "KEY_PGDN", INT2FIX(KEY_PGDN));
  /* KEY_LEFT: */
  rb_define_const(mAllegro4r_API, "KEY_LEFT", INT2FIX(KEY_LEFT));
  /* KEY_RIGHT: */
  rb_define_const(mAllegro4r_API, "KEY_RIGHT", INT2FIX(KEY_RIGHT));
  /* KEY_UP: */
  rb_define_const(mAllegro4r_API, "KEY_UP", INT2FIX(KEY_UP));
  /* KEY_DOWN: */
  rb_define_const(mAllegro4r_API, "KEY_DOWN", INT2FIX(KEY_DOWN));
  /* KEY_SLASH_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_SLASH_PAD", INT2FIX(KEY_SLASH_PAD));
  /* KEY_ASTERISK: */
  rb_define_const(mAllegro4r_API, "KEY_ASTERISK", INT2FIX(KEY_ASTERISK));
  /* KEY_MINUS_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_MINUS_PAD", INT2FIX(KEY_MINUS_PAD));
  /* KEY_PLUS_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_PLUS_PAD", INT2FIX(KEY_PLUS_PAD));
  /* KEY_DEL_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_DEL_PAD", INT2FIX(KEY_DEL_PAD));
  /* KEY_ENTER_PAD: */
  rb_define_const(mAllegro4r_API, "KEY_ENTER_PAD", INT2FIX(KEY_ENTER_PAD));
  /* KEY_PRTSCR: */
  rb_define_const(mAllegro4r_API, "KEY_PRTSCR", INT2FIX(KEY_PRTSCR));
  /* KEY_PAUSE: */
  rb_define_const(mAllegro4r_API, "KEY_PAUSE", INT2FIX(KEY_PAUSE));
  /* KEY_ABNT_C1: */
  rb_define_const(mAllegro4r_API, "KEY_ABNT_C1", INT2FIX(KEY_ABNT_C1));
  /* KEY_YEN: */
  rb_define_const(mAllegro4r_API, "KEY_YEN", INT2FIX(KEY_YEN));
  /* KEY_KANA: */
  rb_define_const(mAllegro4r_API, "KEY_KANA", INT2FIX(KEY_KANA));
  /* KEY_CONVERT: */
  rb_define_const(mAllegro4r_API, "KEY_CONVERT", INT2FIX(KEY_CONVERT));
  /* KEY_NOCONVERT: */
  rb_define_const(mAllegro4r_API, "KEY_NOCONVERT", INT2FIX(KEY_NOCONVERT));
  /* KEY_AT: */
  rb_define_const(mAllegro4r_API, "KEY_AT", INT2FIX(KEY_AT));
  /* KEY_CIRCUMFLEX: */
  rb_define_const(mAllegro4r_API, "KEY_CIRCUMFLEX", INT2FIX(KEY_CIRCUMFLEX));
  /* KEY_COLON2: */
  rb_define_const(mAllegro4r_API, "KEY_COLON2", INT2FIX(KEY_COLON2));
  /* KEY_KANJI: */
  rb_define_const(mAllegro4r_API, "KEY_KANJI", INT2FIX(KEY_KANJI));
  /* KEY_EQUALS_PAD: MacOS X*/
  rb_define_const(mAllegro4r_API, "KEY_EQUALS_PAD", INT2FIX(KEY_EQUALS_PAD));
  /* KEY_BACKQUOTE: MacOS X*/
  rb_define_const(mAllegro4r_API, "KEY_BACKQUOTE", INT2FIX(KEY_BACKQUOTE));
  /* KEY_SEMICOLON: MacOS X*/
  rb_define_const(mAllegro4r_API, "KEY_SEMICOLON", INT2FIX(KEY_SEMICOLON));
  /* KEY_COMMAND: MacOS X*/
  rb_define_const(mAllegro4r_API, "KEY_COMMAND", INT2FIX(KEY_COMMAND));
  /* KEY_UNKNOWN1: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN1", INT2FIX(KEY_UNKNOWN1));
  /* KEY_UNKNOWN2: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN2", INT2FIX(KEY_UNKNOWN2));
  /* KEY_UNKNOWN3: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN3", INT2FIX(KEY_UNKNOWN3));
  /* KEY_UNKNOWN4: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN4", INT2FIX(KEY_UNKNOWN4));
  /* KEY_UNKNOWN5: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN5", INT2FIX(KEY_UNKNOWN5));
  /* KEY_UNKNOWN6: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN6", INT2FIX(KEY_UNKNOWN6));
  /* KEY_UNKNOWN7: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN7", INT2FIX(KEY_UNKNOWN7));
  /* KEY_UNKNOWN8: */
  rb_define_const(mAllegro4r_API, "KEY_UNKNOWN8", INT2FIX(KEY_UNKNOWN8));
  /* KEY_MODIFIERS: */
  rb_define_const(mAllegro4r_API, "KEY_MODIFIERS", INT2FIX(KEY_MODIFIERS));
  /* KEY_LSHIFT: */
  rb_define_const(mAllegro4r_API, "KEY_LSHIFT", INT2FIX(KEY_LSHIFT));
  /* KEY_RSHIFT: */
  rb_define_const(mAllegro4r_API, "KEY_RSHIFT", INT2FIX(KEY_RSHIFT));
  /* KEY_LCONTROL: */
  rb_define_const(mAllegro4r_API, "KEY_LCONTROL", INT2FIX(KEY_LCONTROL));
  /* KEY_RCONTROL: */
  rb_define_const(mAllegro4r_API, "KEY_RCONTROL", INT2FIX(KEY_RCONTROL));
  /* KEY_ALT: */
  rb_define_const(mAllegro4r_API, "KEY_ALT", INT2FIX(KEY_ALT));
  /* KEY_ALTGR: */
  rb_define_const(mAllegro4r_API, "KEY_ALTGR", INT2FIX(KEY_ALTGR));
  /* KEY_LWIN: */
  rb_define_const(mAllegro4r_API, "KEY_LWIN", INT2FIX(KEY_LWIN));
  /* KEY_RWIN: */
  rb_define_const(mAllegro4r_API, "KEY_RWIN", INT2FIX(KEY_RWIN));
  /* KEY_MENU: */
  rb_define_const(mAllegro4r_API, "KEY_MENU", INT2FIX(KEY_MENU));
  /* KEY_SCRLOCK: */
  rb_define_const(mAllegro4r_API, "KEY_SCRLOCK", INT2FIX(KEY_SCRLOCK));
  /* KEY_NUMLOCK: */
  rb_define_const(mAllegro4r_API, "KEY_NUMLOCK", INT2FIX(KEY_NUMLOCK));
  /* KEY_CAPSLOCK: */
  rb_define_const(mAllegro4r_API, "KEY_CAPSLOCK", INT2FIX(KEY_CAPSLOCK));
  /* KEY_MAX: */
  rb_define_const(mAllegro4r_API, "KEY_MAX", INT2FIX(KEY_MAX));

  /* JOY_TYPE_AUTODETECT: */
  rb_define_const(mAllegro4r_API, "JOY_TYPE_AUTODETECT", INT2FIX(JOY_TYPE_AUTODETECT));
  /* JOY_TYPE_NONE: */
  rb_define_const(mAllegro4r_API, "JOY_TYPE_NONE", INT2FIX(JOY_TYPE_NONE));

  /* JOYFLAG_DIGITAL: This control is currently providing digital input. */
  rb_define_const(mAllegro4r_API, "JOYFLAG_DIGITAL", INT2FIX(JOYFLAG_DIGITAL));
  /* JOYFLAG_ANALOGUE: This control is currently providing analogue input. */
  rb_define_const(mAllegro4r_API, "JOYFLAG_ANALOGUE", INT2FIX(JOYFLAG_ANALOGUE));
  /*
   * JOYFLAG_CALIB_DIGITAL: This control will be capable of providing digital
   * input once it has been calibrated, but is not doing this at the moment.
   */
  rb_define_const(mAllegro4r_API, "JOYFLAG_CALIB_DIGITAL", INT2FIX(JOYFLAG_CALIB_DIGITAL));
  /*
   * JOYFLAG_CALIB_ANALOGUE: This control will be capable of providing analogue
   * input once it has been calibrated, but is not doing this at the moment.
   */
  rb_define_const(mAllegro4r_API, "JOYFLAG_CALIB_ANALOGUE", INT2FIX(JOYFLAG_CALIB_ANALOGUE));
  /*
   * JOYFLAG_CALIBRATE: Indicates that this control needs to be calibrated. Many
   * devices require multiple calibration steps, so you should call the
   * calibrate_joystick function from a loop until this flag is cleared.
   */
  rb_define_const(mAllegro4r_API, "JOYFLAG_CALIBRATE", INT2FIX(JOYFLAG_CALIBRATE));
  /*
   * JOYFLAG_SIGNED: Indicates that the analogue axis position is in signed
   * format, ranging from -128 to 128. This is the case for all 2d directional
   * controls.
   */
  rb_define_const(mAllegro4r_API, "JOYFLAG_SIGNED", INT2FIX(JOYFLAG_SIGNED));
  /*
   * JOYFLAG_UNSIGNED: Indicates that the analogue axis position is in unsigned
   * format, ranging from 0 to 255. This is the case for all 1d throttle
   * controls.
   */
  rb_define_const(mAllegro4r_API, "JOYFLAG_UNSIGNED", INT2FIX(JOYFLAG_UNSIGNED));

  /* DIGI_AUTODETECT: Let Allegro pick a digital sound driver */
  rb_define_const(mAllegro4r_API, "DIGI_AUTODETECT", INT2FIX(DIGI_AUTODETECT));
  /* DIGI_NONE: No digital sound */
  rb_define_const(mAllegro4r_API, "DIGI_NONE", INT2FIX(DIGI_NONE));

  /* MIDI_AUTODETECT: Let Allegro pick a MIDI sound driver */
  rb_define_const(mAllegro4r_API, "MIDI_AUTODETECT", INT2FIX(MIDI_AUTODETECT));
  /* MIDI_NONE: No MIDI sound */
  rb_define_const(mAllegro4r_API, "MIDI_NONE", INT2FIX(MIDI_NONE));
}
コード例 #9
0
ファイル: syslog.c プロジェクト: brightbox/deb-ruby1.9.1
/* The syslog package provides a Ruby interface to the POSIX system logging
 * facility.
 *
 * Syslog messages are typically passed to a central logging daemon.
 * The daemon may filter them; route them into different files (usually
 * found under /var/log); place them in SQL databases; forward
 * them to centralized logging servers via TCP or UDP; or even alert the
 * system administrator via email, pager or text message.
 *
 * Unlike application-level logging via Logger or Log4r, syslog is designed
 * to allow secure tamper-proof logging.
 *
 * The syslog protocol is standardized in RFC 5424.
 */
void Init_syslog()
{
    mSyslog = rb_define_module("Syslog");

    /* Document-module: Syslog::Constants
     *
     * Module holding Syslog constants.  See Syslog::log and Syslog::open for
     * constant descriptions.
     */
    mSyslogConstants = rb_define_module_under(mSyslog, "Constants");

    rb_include_module(mSyslog, mSyslogConstants);

    rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
    rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
    rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
    rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);

    rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
    rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
    rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);

    rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
    rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
    rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
    rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);

    rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
    rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);

    rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0);
    rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);

    rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
    rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);

#define rb_define_syslog_const(id) \
    rb_define_const(mSyslogConstants, #id, INT2NUM(id))

    /* Various options when opening log */
#ifdef LOG_PID
    rb_define_syslog_const(LOG_PID);
#endif
#ifdef LOG_CONS
    rb_define_syslog_const(LOG_CONS);
#endif
#ifdef LOG_ODELAY
    rb_define_syslog_const(LOG_ODELAY); /* deprecated */
#endif
#ifdef LOG_NDELAY
    rb_define_syslog_const(LOG_NDELAY);
#endif
#ifdef LOG_NOWAIT
    rb_define_syslog_const(LOG_NOWAIT); /* deprecated */
#endif
#ifdef LOG_PERROR
    rb_define_syslog_const(LOG_PERROR);
#endif

    /* Various syslog facilities */
#ifdef LOG_AUTH
    rb_define_syslog_const(LOG_AUTH);
#endif
#ifdef LOG_AUTHPRIV
    rb_define_syslog_const(LOG_AUTHPRIV);
#endif
#ifdef LOG_CONSOLE
    rb_define_syslog_const(LOG_CONSOLE);
#endif
#ifdef LOG_CRON
    rb_define_syslog_const(LOG_CRON);
#endif
#ifdef LOG_DAEMON
    rb_define_syslog_const(LOG_DAEMON);
#endif
#ifdef LOG_FTP
    rb_define_syslog_const(LOG_FTP);
#endif
#ifdef LOG_KERN
    rb_define_syslog_const(LOG_KERN);
#endif
#ifdef LOG_LPR
    rb_define_syslog_const(LOG_LPR);
#endif
#ifdef LOG_MAIL
    rb_define_syslog_const(LOG_MAIL);
#endif
#ifdef LOG_NEWS
    rb_define_syslog_const(LOG_NEWS);
#endif
#ifdef LOG_NTP
   rb_define_syslog_const(LOG_NTP);
#endif
#ifdef LOG_SECURITY
    rb_define_syslog_const(LOG_SECURITY);
#endif
#ifdef LOG_SYSLOG
    rb_define_syslog_const(LOG_SYSLOG);
#endif
#ifdef LOG_USER
    rb_define_syslog_const(LOG_USER);
#endif
#ifdef LOG_UUCP
    rb_define_syslog_const(LOG_UUCP);
#endif
#ifdef LOG_LOCAL0
    rb_define_syslog_const(LOG_LOCAL0);
#endif
#ifdef LOG_LOCAL1
    rb_define_syslog_const(LOG_LOCAL1);
#endif
#ifdef LOG_LOCAL2
    rb_define_syslog_const(LOG_LOCAL2);
#endif
#ifdef LOG_LOCAL3
    rb_define_syslog_const(LOG_LOCAL3);
#endif
#ifdef LOG_LOCAL4
    rb_define_syslog_const(LOG_LOCAL4);
#endif
#ifdef LOG_LOCAL5
    rb_define_syslog_const(LOG_LOCAL5);
#endif
#ifdef LOG_LOCAL6
    rb_define_syslog_const(LOG_LOCAL6);
#endif
#ifdef LOG_LOCAL7
    rb_define_syslog_const(LOG_LOCAL7);
#endif

#define rb_define_syslog_shortcut(name) \
    rb_define_module_function(mSyslog, #name, mSyslog_##name, -1)

    /* Various syslog priorities and the shortcut methods */
#ifdef LOG_EMERG
    rb_define_syslog_const(LOG_EMERG);
    rb_define_syslog_shortcut(emerg);
#endif
#ifdef LOG_ALERT
    rb_define_syslog_const(LOG_ALERT);
    rb_define_syslog_shortcut(alert);
#endif
#ifdef LOG_CRIT
    rb_define_syslog_const(LOG_CRIT);
    rb_define_syslog_shortcut(crit);
#endif
#ifdef LOG_ERR
    rb_define_syslog_const(LOG_ERR);
    rb_define_syslog_shortcut(err);
#endif
#ifdef LOG_WARNING
    rb_define_syslog_const(LOG_WARNING);
    rb_define_syslog_shortcut(warning);
#endif
#ifdef LOG_NOTICE
    rb_define_syslog_const(LOG_NOTICE);
    rb_define_syslog_shortcut(notice);
#endif
#ifdef LOG_INFO
    rb_define_syslog_const(LOG_INFO);
    rb_define_syslog_shortcut(info);
#endif
#ifdef LOG_DEBUG
    rb_define_syslog_const(LOG_DEBUG);
    rb_define_syslog_shortcut(debug);
#endif
}
コード例 #10
0
ファイル: client.c プロジェクト: OliverTruong/mysql2
void init_mysql2_client() {
  /* verify the libmysql we're about to use was the version we were built against
     https://github.com/luislavena/mysql-gem/commit/a600a9c459597da0712f70f43736e24b484f8a99 */
  int i;
  int dots = 0;
  const char *lib = mysql_get_client_info();

  for (i = 0; lib[i] != 0 && MYSQL_LINK_VERSION[i] != 0; i++) {
    if (lib[i] == '.') {
      dots++;
              /* we only compare MAJOR and MINOR */
      if (dots == 2) break;
    }
    if (lib[i] != MYSQL_LINK_VERSION[i]) {
      rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_LINK_VERSION, lib);
      return;
    }
  }

#if 0
  mMysql2      = rb_define_module("Mysql2"); Teach RDoc about Mysql2 constant.
#endif
  cMysql2Client = rb_define_class_under(mMysql2, "Client", rb_cObject);

  rb_define_alloc_func(cMysql2Client, allocate);

  rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 1);

  rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0);
  rb_define_method(cMysql2Client, "query", rb_mysql_client_query, -1);
  rb_define_method(cMysql2Client, "abandon_results!", rb_mysql_client_abandon_results, 0);
  rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_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_method(cMysql2Client, "thread_id", rb_mysql_client_thread_id, 0);
  rb_define_method(cMysql2Client, "ping", rb_mysql_client_ping, 0);
  rb_define_method(cMysql2Client, "select_db", rb_mysql_client_select_db, 1);
  rb_define_method(cMysql2Client, "more_results?", rb_mysql_client_more_results, 0);
  rb_define_method(cMysql2Client, "next_result", rb_mysql_client_next_result, 0);
  rb_define_method(cMysql2Client, "store_result", rb_mysql_client_store_result, 0);
  rb_define_method(cMysql2Client, "reconnect=", set_reconnect, 1);
  rb_define_method(cMysql2Client, "warning_count", rb_mysql_client_warning_count, 0);
  rb_define_method(cMysql2Client, "query_info_string", rb_mysql_info, 0);
#ifdef HAVE_RUBY_ENCODING_H
  rb_define_method(cMysql2Client, "encoding", rb_mysql_client_encoding, 0);
#endif

  rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1);
  rb_define_private_method(cMysql2Client, "read_timeout=", set_read_timeout, 1);
  rb_define_private_method(cMysql2Client, "write_timeout=", set_write_timeout, 1);
  rb_define_private_method(cMysql2Client, "local_infile=", set_local_infile, 1);
  rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1);
  rb_define_private_method(cMysql2Client, "secure_auth=", set_secure_auth, 1);
  rb_define_private_method(cMysql2Client, "default_file=", set_read_default_file, 1);
  rb_define_private_method(cMysql2Client, "default_group=", set_read_default_group, 1);
  rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
  rb_define_private_method(cMysql2Client, "initialize_ext", initialize_ext, 0);
  rb_define_private_method(cMysql2Client, "connect", rb_connect, 7);

  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"));
  sym_stream          = ID2SYM(rb_intern("stream"));

  intern_merge = rb_intern("merge");
  intern_merge_bang = 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"),
      LONG2NUM(CLIENT_LONG_PASSWORD));
#endif

#ifdef CLIENT_FOUND_ROWS
  rb_const_set(cMysql2Client, rb_intern("FOUND_ROWS"),
      LONG2NUM(CLIENT_FOUND_ROWS));
#endif

#ifdef CLIENT_LONG_FLAG
  rb_const_set(cMysql2Client, rb_intern("LONG_FLAG"),
      LONG2NUM(CLIENT_LONG_FLAG));
#endif

#ifdef CLIENT_CONNECT_WITH_DB
  rb_const_set(cMysql2Client, rb_intern("CONNECT_WITH_DB"),
      LONG2NUM(CLIENT_CONNECT_WITH_DB));
#endif

#ifdef CLIENT_NO_SCHEMA
  rb_const_set(cMysql2Client, rb_intern("NO_SCHEMA"),
      LONG2NUM(CLIENT_NO_SCHEMA));
#endif

#ifdef CLIENT_COMPRESS
  rb_const_set(cMysql2Client, rb_intern("COMPRESS"), LONG2NUM(CLIENT_COMPRESS));
#endif

#ifdef CLIENT_ODBC
  rb_const_set(cMysql2Client, rb_intern("ODBC"), LONG2NUM(CLIENT_ODBC));
#endif

#ifdef CLIENT_LOCAL_FILES
  rb_const_set(cMysql2Client, rb_intern("LOCAL_FILES"),
      LONG2NUM(CLIENT_LOCAL_FILES));
#endif

#ifdef CLIENT_IGNORE_SPACE
  rb_const_set(cMysql2Client, rb_intern("IGNORE_SPACE"),
      LONG2NUM(CLIENT_IGNORE_SPACE));
#endif

#ifdef CLIENT_PROTOCOL_41
  rb_const_set(cMysql2Client, rb_intern("PROTOCOL_41"),
      LONG2NUM(CLIENT_PROTOCOL_41));
#endif

#ifdef CLIENT_INTERACTIVE
  rb_const_set(cMysql2Client, rb_intern("INTERACTIVE"),
      LONG2NUM(CLIENT_INTERACTIVE));
#endif

#ifdef CLIENT_SSL
  rb_const_set(cMysql2Client, rb_intern("SSL"), LONG2NUM(CLIENT_SSL));
#endif

#ifdef CLIENT_IGNORE_SIGPIPE
  rb_const_set(cMysql2Client, rb_intern("IGNORE_SIGPIPE"),
      LONG2NUM(CLIENT_IGNORE_SIGPIPE));
#endif

#ifdef CLIENT_TRANSACTIONS
  rb_const_set(cMysql2Client, rb_intern("TRANSACTIONS"),
      LONG2NUM(CLIENT_TRANSACTIONS));
#endif

#ifdef CLIENT_RESERVED
  rb_const_set(cMysql2Client, rb_intern("RESERVED"), LONG2NUM(CLIENT_RESERVED));
#endif

#ifdef CLIENT_SECURE_CONNECTION
  rb_const_set(cMysql2Client, rb_intern("SECURE_CONNECTION"),
      LONG2NUM(CLIENT_SECURE_CONNECTION));
#endif

#ifdef CLIENT_MULTI_STATEMENTS
  rb_const_set(cMysql2Client, rb_intern("MULTI_STATEMENTS"),
      LONG2NUM(CLIENT_MULTI_STATEMENTS));
#endif

#ifdef CLIENT_PS_MULTI_RESULTS
  rb_const_set(cMysql2Client, rb_intern("PS_MULTI_RESULTS"),
      LONG2NUM(CLIENT_PS_MULTI_RESULTS));
#endif

#ifdef CLIENT_SSL_VERIFY_SERVER_CERT
  rb_const_set(cMysql2Client, rb_intern("SSL_VERIFY_SERVER_CERT"),
      LONG2NUM(CLIENT_SSL_VERIFY_SERVER_CERT));
#endif

#ifdef CLIENT_REMEMBER_OPTIONS
  rb_const_set(cMysql2Client, rb_intern("REMEMBER_OPTIONS"),
      LONG2NUM(CLIENT_REMEMBER_OPTIONS));
#endif

#ifdef CLIENT_ALL_FLAGS
  rb_const_set(cMysql2Client, rb_intern("ALL_FLAGS"),
      LONG2NUM(CLIENT_ALL_FLAGS));
#endif

#ifdef CLIENT_BASIC_FLAGS
  rb_const_set(cMysql2Client, rb_intern("BASIC_FLAGS"),
      LONG2NUM(CLIENT_BASIC_FLAGS));
#endif
}
コード例 #11
0
/**
 * Load a Ruby file then run the function corresponding to the service by
 * passing the conf, inputs and outputs parameters by refernce as Ruby Hash.
 *
 * @param main_conf the conf maps containing the main.cfg settings
 * @param request the map containing the HTTP request
 * @param s the service structure
 * @param real_inputs the maps containing the inputs
 * @param real_outputs the maps containing the outputs
 * @return SERVICE_SUCCEEDED or SERVICE_FAILED if the service run, -1 
 *  if the service failed to load or throw error at runtime.
 */
int zoo_ruby_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
#if RUBY_API_VERSION_MAJOR >= 2 || RUBY_API_VERSION_MINOR == 9
  ruby_sysinit(&argc,&argv);
  RUBY_INIT_STACK;
#endif
  ruby_init();
  maps* m=*main_conf;
  maps* inputs=*real_inputs;
  maps* outputs=*real_outputs;
  map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd");
  char *ntmp=tmp0->value;
  map* tmp=NULL;
  ruby_init_loadpath();
  ruby_script("ZOO_EMBEDDED_ENV");
  
  VALUE klass=rb_define_module("Zoo");
  rb_define_const(klass,"SERVICE_SUCCEEDED",INT2FIX(3));
  rb_define_const(klass,"SERVICE_FAILED",INT2FIX(4));
  typedef VALUE (*HOOK)(...);
  rb_define_module_function(klass,"Translate",reinterpret_cast<HOOK>(RubyTranslate),-1);
  rb_define_module_function(klass,"UpdateStatus",reinterpret_cast<HOOK>(RubyUpdateStatus),-1);

  int error = 0;
		
  ID rFunc=Qnil;
  tmp=getMap(s->content,"serviceProvider");
  if(tmp!=NULL){
#if RUBY_VERSION_MINOR == 8
    const char* script = ruby_sourcefile = rb_source_filename(tmp->value);
    rb_protect(LoadWrap, reinterpret_cast<VALUE>(script), &error);
#else
    rb_load_protect(rb_str_new2(tmp->value), 0, &error);
#endif
    if(error) {
      ruby_trace_error(m);
      return -1;
    }
#if RUBY_VERSION_MINOR == 8
    ruby_exec();
#else
    ruby_exec_node(NULL);
#endif
  }
  else{
    map* err=createMap("text","Unable to parse serviceProvider please check your zcfg file.");
    addToMap(err,"code","NoApplicableCode");
    printExceptionReportResponse(m,err);
    return -1;
  }
  int res=SERVICE_FAILED;
  rFunc=rb_intern(s->name);
  if(rFunc!=Qnil){
    VALUE arg1=RubyHash_FromMaps(m);
    VALUE arg2=RubyHash_FromMaps(inputs);
    VALUE arg3=RubyHash_FromMaps(outputs);
    VALUE rArgs[3]={arg1,arg2,arg3};
    if (!rArgs)
      return -1;
    struct my_callback data;
    data.obj=Qnil;
    data.method_id=rFunc;
    data.nargs=3;
    data.args[0]=rArgs[0];
    data.args[1]=rArgs[1];
    data.args[2]=rArgs[2];
    typedef VALUE (*HOOK)(VALUE);
    VALUE tres=rb_protect(reinterpret_cast<HOOK>(FunCallWrap),(VALUE)(&data),&error);
    if (TYPE(tres) == T_FIXNUM) {
      res=FIX2INT(tres);
      freeMaps(real_outputs);
      free(*real_outputs);
      freeMaps(main_conf);
      free(*main_conf);
      *main_conf=mapsFromRubyHash(arg1);
      *real_outputs=mapsFromRubyHash(arg3);
#ifdef DEBUG
      dumpMaps(*main_conf);
      dumpMaps(*real_outputs);
#endif
    }else{
      ruby_trace_error(m);
      res=-1;
    }
  }
  else{
    char tmpS[1024];
    sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value);
    map* tmps=createMap("text",tmpS);
    printExceptionReportResponse(m,tmps);
    res=-1;
  }
  ruby_finalize();
  return res;
}
コード例 #12
0
ファイル: ossl_cipher.c プロジェクト: sho-h/ruby
/*
 * INIT
 */
void
Init_ossl_cipher(void)
{
#if 0
    mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
#endif

    /* Document-class: OpenSSL::Cipher
     *
     * Provides symmetric algorithms for encryption and decryption. The
     * algorithms that are available depend on the particular version
     * of OpenSSL that is installed.
     *
     * === Listing all supported algorithms
     *
     * A list of supported algorithms can be obtained by
     *
     *   puts OpenSSL::Cipher.ciphers
     *
     * === Instantiating a Cipher
     *
     * There are several ways to create a Cipher instance. Generally, a
     * Cipher algorithm is categorized by its name, the key length in bits
     * and the cipher mode to be used. The most generic way to create a
     * Cipher is the following
     *
     *   cipher = OpenSSL::Cipher.new('<name>-<key length>-<mode>')
     *
     * That is, a string consisting of the hyphenated concatenation of the
     * individual components name, key length and mode. Either all uppercase
     * or all lowercase strings may be used, for example:
     *
     *  cipher = OpenSSL::Cipher.new('AES-128-CBC')
     *
     * For each algorithm supported, there is a class defined under the
     * Cipher class that goes by the name of the cipher, e.g. to obtain an
     * instance of AES, you could also use
     *
     *   # these are equivalent
     *   cipher = OpenSSL::Cipher::AES.new(128, :CBC)
     *   cipher = OpenSSL::Cipher::AES.new(128, 'CBC')
     *   cipher = OpenSSL::Cipher::AES.new('128-CBC')
     *
     * Finally, due to its wide-spread use, there are also extra classes
     * defined for the different key sizes of AES
     *
     *   cipher = OpenSSL::Cipher::AES128.new(:CBC)
     *   cipher = OpenSSL::Cipher::AES192.new(:CBC)
     *   cipher = OpenSSL::Cipher::AES256.new(:CBC)
     *
     * === Choosing either encryption or decryption mode
     *
     * Encryption and decryption are often very similar operations for
     * symmetric algorithms, this is reflected by not having to choose
     * different classes for either operation, both can be done using the
     * same class. Still, after obtaining a Cipher instance, we need to
     * tell the instance what it is that we intend to do with it, so we
     * need to call either
     *
     *   cipher.encrypt
     *
     * or
     *
     *   cipher.decrypt
     *
     * on the Cipher instance. This should be the first call after creating
     * the instance, otherwise configuration that has already been set could
     * get lost in the process.
     *
     * === Choosing a key
     *
     * Symmetric encryption requires a key that is the same for the encrypting
     * and for the decrypting party and after initial key establishment should
     * be kept as private information. There are a lot of ways to create
     * insecure keys, the most notable is to simply take a password as the key
     * without processing the password further. A simple and secure way to
     * create a key for a particular Cipher is
     *
     *  cipher = OpenSSL::AES256.new(:CFB)
     *  cipher.encrypt
     *  key = cipher.random_key # also sets the generated key on the Cipher
     *
     * If you absolutely need to use passwords as encryption keys, you
     * should use Password-Based Key Derivation Function 2 (PBKDF2) by
     * generating the key with the help of the functionality provided by
     * OpenSSL::PKCS5.pbkdf2_hmac_sha1 or OpenSSL::PKCS5.pbkdf2_hmac.
     *
     * Although there is Cipher#pkcs5_keyivgen, its use is deprecated and
     * it should only be used in legacy applications because it does not use
     * the newer PKCS#5 v2 algorithms.
     *
     * === Choosing an IV
     *
     * The cipher modes CBC, CFB, OFB and CTR all need an "initialization
     * vector", or short, IV. ECB mode is the only mode that does not require
     * an IV, but there is almost no legitimate use case for this mode
     * because of the fact that it does not sufficiently hide plaintext
     * patterns. Therefore
     *
     * <b>You should never use ECB mode unless you are absolutely sure that
     * you absolutely need it</b>
     *
     * Because of this, you will end up with a mode that explicitly requires
     * an IV in any case. Note that for backwards compatibility reasons,
     * setting an IV is not explicitly mandated by the Cipher API. If not
     * set, OpenSSL itself defaults to an all-zeroes IV ("\\0", not the
     * character). Although the IV can be seen as public information, i.e.
     * it may be transmitted in public once generated, it should still stay
     * unpredictable to prevent certain kinds of attacks. Therefore, ideally
     *
     * <b>Always create a secure random IV for every encryption of your
     * Cipher</b>
     *
     * A new, random IV should be created for every encryption of data. Think
     * of the IV as a nonce (number used once) - it's public but random and
     * unpredictable. A secure random IV can be created as follows
     *
     *  cipher = ...
     *  cipher.encrypt
     *  key = cipher.random_key
     *  iv = cipher.random_iv # also sets the generated IV on the Cipher
     *
     *  Although the key is generally a random value, too, it is a bad choice
     *  as an IV. There are elaborate ways how an attacker can take advantage
     *  of such an IV. As a general rule of thumb, exposing the key directly
     *  or indirectly should be avoided at all cost and exceptions only be
     *  made with good reason.
     *
     * === Calling Cipher#final
     *
     * ECB (which should not be used) and CBC are both block-based modes.
     * This means that unlike for the other streaming-based modes, they
     * operate on fixed-size blocks of data, and therefore they require a
     * "finalization" step to produce or correctly decrypt the last block of
     * data by appropriately handling some form of padding. Therefore it is
     * essential to add the output of OpenSSL::Cipher#final to your
     * encryption/decryption buffer or you will end up with decryption errors
     * or truncated data.
     *
     * Although this is not really necessary for streaming-mode ciphers, it is
     * still recommended to apply the same pattern of adding the output of
     * Cipher#final there as well - it also enables you to switch between
     * modes more easily in the future.
     *
     * === Encrypting and decrypting some data
     *
     *   data = "Very, very confidential data"
     *
     *   cipher = OpenSSL::Cipher::AES.new(128, :CBC)
     *   cipher.encrypt
     *   key = cipher.random_key
     *   iv = cipher.random_iv
     *
     *   encrypted = cipher.update(data) + cipher.final
     *   ...
     *   decipher = OpenSSL::Cipher::AES.new(128, :CBC)
     *   decipher.decrypt
     *   decipher.key = key
     *   decipher.iv = iv
     *
     *   plain = decipher.update(encrypted) + decipher.final
     *
     *   puts data == plain #=> true
     *
     * === Authenticated Encryption and Associated Data (AEAD)
     *
     * If the OpenSSL version used supports it, an Authenticated Encryption
     * mode (such as GCM or CCM) should always be preferred over any
     * unauthenticated mode. Currently, OpenSSL supports AE only in combination
     * with Associated Data (AEAD) where additional associated data is included
     * in the encryption process to compute a tag at the end of the encryption.
     * This tag will also be used in the decryption process and by verifying
     * its validity, the authenticity of a given ciphertext is established.
     *
     * This is superior to unauthenticated modes in that it allows to detect
     * if somebody effectively changed the ciphertext after it had been
     * encrypted. This prevents malicious modifications of the ciphertext that
     * could otherwise be exploited to modify ciphertexts in ways beneficial to
     * potential attackers.
     *
     * If no associated data is needed for encryption and later decryption,
     * the OpenSSL library still requires a value to be set - "" may be used in
     * case none is available. An example using the GCM (Galois Counter Mode):
     *
     *   cipher = OpenSSL::Cipher::AES.new(128, :GCM)
     *   cipher.encrypt
     *   key = cipher.random_key
     *   iv = cipher.random_iv
     *   cipher.auth_data = ""
     *
     *   encrypted = cipher.update(data) + cipher.final
     *   tag = cipher.auth_tag
     *
     *   decipher = OpenSSL::Cipher::AES.new(128, :GCM)
     *   decipher.decrypt
     *   decipher.key = key
     *   decipher.iv = iv
     *   decipher.auth_tag = tag
     *   decipher.auth_data = ""
     *
     *   plain = decipher.update(encrypted) + decipher.final
     *
     *   puts data == plain #=> true
     */
    cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
    eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);

    rb_define_alloc_func(cCipher, ossl_cipher_alloc);
    rb_define_copy_func(cCipher, ossl_cipher_copy);
    rb_define_module_function(cCipher, "ciphers", ossl_s_ciphers, 0);
    rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
    rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
    rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
    rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
    rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
    rb_define_method(cCipher, "update", ossl_cipher_update, -1);
    rb_define_method(cCipher, "final", ossl_cipher_final, 0);
    rb_define_method(cCipher, "name", ossl_cipher_name, 0);
    rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
    rb_define_method(cCipher, "auth_data=", ossl_cipher_set_auth_data, 1);
    rb_define_method(cCipher, "auth_tag=", ossl_cipher_set_auth_tag, 1);
    rb_define_method(cCipher, "auth_tag", ossl_cipher_get_auth_tag, -1);
    rb_define_method(cCipher, "authenticated?", ossl_cipher_is_authenticated, 0);
    rb_define_method(cCipher, "key_len=", ossl_cipher_set_key_length, 1);
    rb_define_method(cCipher, "key_len", ossl_cipher_key_length, 0);
    rb_define_method(cCipher, "iv=", ossl_cipher_set_iv, 1);
    rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0);
    rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
    rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
}
コード例 #13
0
ファイル: rbzoomconnection.c プロジェクト: icleversoft/zoom
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "rbzoom.h"

#ifdef MAKING_RDOC_HAPPY
mZoom = rb_define_module("ZOOM");
#endif


/* Document-class: ZOOM::Connection
 * The Connection object is a session with a target.
 */
static VALUE cZoomConnection;


static VALUE
rbz_connection_make (ZOOM_connection connection)
{
    return connection != NULL
        ? Data_Wrap_Struct (cZoomConnection,
                            NULL,
コード例 #14
0
ファイル: simplemixed.c プロジェクト: 2maz/gem2deb
void Init_simplemixed() {
  rb_define_module("SimpleMixed");
}
コード例 #15
0
ファイル: pg.c プロジェクト: RapsIn4/pg
void
Init_pg_ext()
{
	rb_mPG = rb_define_module( "PG" );
	rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );

	/*************************
	 *  PG module methods
	 *************************/
#ifdef HAVE_PQLIBVERSION
	rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
#endif
	rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
	SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
	SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );

  rb_define_singleton_method( rb_mPG, "init_openssl", pg_s_init_openssl, 2 );
  rb_define_singleton_method( rb_mPG, "init_ssl", pg_s_init_ssl, 1 );


	/******     PG::Connection CLASS CONSTANTS: Connection Status     ******/

	/* Connection succeeded */
	rb_define_const(rb_mPGconstants, "CONNECTION_OK", INT2FIX(CONNECTION_OK));
	/* Connection failed */
	rb_define_const(rb_mPGconstants, "CONNECTION_BAD", INT2FIX(CONNECTION_BAD));

	/******     PG::Connection CLASS CONSTANTS: Nonblocking connection status     ******/

	/* Waiting for connection to be made. */
	rb_define_const(rb_mPGconstants, "CONNECTION_STARTED", INT2FIX(CONNECTION_STARTED));
	/* Connection OK; waiting to send. */
	rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
	/* Waiting for a response from the server. */
	rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
	/* Received authentication; waiting for backend start-up to finish. */
	rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
	/* Negotiating SSL encryption. */
	rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
	/* Negotiating environment-driven parameter settings. */
	rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
	/* Internal state: connect() needed. */
	rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));

	/******     PG::Connection CLASS CONSTANTS: Nonblocking connection polling status     ******/

	/* Async connection is waiting to read */
	rb_define_const(rb_mPGconstants, "PGRES_POLLING_READING", INT2FIX(PGRES_POLLING_READING));
	/* Async connection is waiting to write */
	rb_define_const(rb_mPGconstants, "PGRES_POLLING_WRITING", INT2FIX(PGRES_POLLING_WRITING));
	/* Async connection failed or was reset */
	rb_define_const(rb_mPGconstants, "PGRES_POLLING_FAILED", INT2FIX(PGRES_POLLING_FAILED));
	/* Async connection succeeded */
	rb_define_const(rb_mPGconstants, "PGRES_POLLING_OK", INT2FIX(PGRES_POLLING_OK));

	/******     PG::Connection CLASS CONSTANTS: Transaction Status     ******/

	/* Transaction is currently idle (#transaction_status) */
	rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
	/* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
	rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
	/* Transaction is currently idle, in a valid transaction block (#transaction_status) */
	rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
	/* Transaction is currently idle, in a failed transaction block (#transaction_status) */
	rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
	/* Transaction's connection is bad (#transaction_status) */
	rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));

	/******     PG::Connection CLASS CONSTANTS: Error Verbosity     ******/

	/* Terse error verbosity level (#set_error_verbosity) */
	rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
	/* Default error verbosity level (#set_error_verbosity) */
	rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
	/* Verbose error verbosity level (#set_error_verbosity) */
	rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));

#ifdef HAVE_PQPING
	/******     PG::Connection CLASS CONSTANTS: Check Server Status ******/

	/* Server is accepting connections. */
	rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
	/* Server is alive but rejecting connections. */
	rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
	/* Could not establish connection. */
	rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
	/* Connection not attempted (bad params). */
	rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
#endif

	/******     PG::Connection CLASS CONSTANTS: Large Objects     ******/

	/* Flag for #lo_creat, #lo_open -- open for writing */
	rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
	/* Flag for #lo_creat, #lo_open -- open for reading */
	rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
	/* Flag for #lo_lseek -- seek from object start */
	rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
	/* Flag for #lo_lseek -- seek from current position */
	rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
	/* Flag for #lo_lseek -- seek from object end */
	rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));

	/******     PG::Result CONSTANTS: result status      ******/

	/* #result_status constant: The string sent to the server was empty. */
	rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
	/* #result_status constant: Successful completion of a command returning no data. */
	rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
		/* #result_status constant: Successful completion of a command returning data
	   (such as a SELECT or SHOW). */
	rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
	/* #result_status constant: Copy Out (from server) data transfer started. */
	rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
	/* #result_status constant: Copy In (to server) data transfer started. */
	rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
	/* #result_status constant: The server’s response was not understood. */
	rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
	/* #result_status constant: A nonfatal error (a notice or warning) occurred. */
	rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
	/* #result_status constant: A fatal error occurred. */
	rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
	/* #result_status constant: Copy In/Out data transfer in progress. */
#ifdef HAVE_CONST_PGRES_COPY_BOTH
	rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
#endif
	/* #result_status constant: Single tuple from larger resultset. */
#ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
	rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
#endif

	/******     Result CONSTANTS: result error field codes      ******/

	/* #result_error_field argument constant: The severity; the field contents
	 * are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE,
	 * DEBUG, INFO, or LOG (in a notice message), or a localized translation
	 * of one of these. Always present.
	 */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));

	/* #result_error_field argument constant: The SQLSTATE code for the
	 * error. The SQLSTATE code identies the type of error that has occurred;
	 * it can be used by front-end applications to perform specic operations
	 * (such as er- ror handling) in response to a particular database
	 * error. For a list of the possible SQLSTATE codes, see Appendix A.
	 * This eld is not localizable, and is always present.
	 */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));

	/* #result_error_field argument constant: The primary human-readable
	 * error message (typically one line). Always present. */
	rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));

	/* #result_error_field argument constant: Detail: an optional secondary
	 * error message carrying more detail about the problem. Might run to
	 * multiple lines.
	 */
	rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));

	/* #result_error_field argument constant: Hint: an optional suggestion
	 * what to do about the problem. This is intended to differ from detail
	 * in that it offers advice (potentially inappropriate) rather than
	 * hard facts. Might run to multiple lines.
	 */

	rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
	/* #result_error_field argument constant: A string containing a decimal
	 * integer indicating an error cursor position as an index into the
	 * original statement string. The rst character has index 1, and
	 * positions are measured in characters not bytes.
	 */

	rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
	/* #result_error_field argument constant: This is dened the same as
	 * the PG_DIAG_STATEMENT_POSITION eld, but it is used when the cursor
	 * position refers to an internally generated command rather than the
	 * one submitted by the client. The PG_DIAG_INTERNAL_QUERY eld will
	 * always appear when this eld appears.
	 */

	rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
	/* #result_error_field argument constant: The text of a failed
	 * internally-generated command. This could be, for example, a SQL
	 * query issued by a PL/pgSQL function.
	 */

	rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
	/* #result_error_field argument constant: An indication of the context
	 * in which the error occurred. Presently this includes a call stack
	 * traceback of active procedural language functions and internally-generated
	 * queries. The trace is one entry per line, most recent rst.
	 */

	rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
	/* #result_error_field argument constant: The le name of the source-code
	 * location where the error was reported. */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));

	/* #result_error_field argument constant: The line number of the
	 * source-code location where the error was reported. */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));

	/* #result_error_field argument constant: The name of the source-code
	 * function reporting the error. */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));

#ifdef HAVE_CONST_PG_DIAG_TABLE_NAME
	/* #result_error_field argument constant: If the error was associated with a
	 * specific database object, the name of the schema containing that object, if any. */
	rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));

	/* #result_error_field argument constant: If the error was associated with a
	 *specific table, the name of the table. (When this field is present, the schema name
	 * field provides the name of the table's schema.) */
	rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));

	/* #result_error_field argument constant: If the error was associated with a
	 * specific table column, the name of the column. (When this field is present, the
	 * schema and table name fields identify the table.) */
	rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));

	/* #result_error_field argument constant: If the error was associated with a
	 * specific datatype, the name of the datatype. (When this field is present, the
	 * schema name field provides the name of the datatype's schema.) */
	rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));

	/* #result_error_field argument constant: If the error was associated with a
	 * specific constraint, the name of the constraint. The table or domain that the
	 * constraint belongs to is reported using the fields listed above. (For this
	 * purpose, indexes are treated as constraints, even if they weren't created with
	 * constraint syntax.) */
	rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
#endif

	/* Invalid OID constant */
	rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
	rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));

	/* Add the constants to the toplevel namespace */
	rb_include_module( rb_mPG, rb_mPGconstants );

#ifdef M17N_SUPPORTED
	enc_pg2ruby = st_init_numtable();
#endif

	/* Initialize the main extension classes */
	init_pg_connection();
	init_pg_result();
	init_pg_errors();
	init_pg_type_map();
	init_pg_type_map_all_strings();
	init_pg_type_map_by_class();
	init_pg_type_map_by_column();
	init_pg_type_map_by_mri_type();
	init_pg_type_map_by_oid();
	init_pg_type_map_in_ruby();
	init_pg_coder();
	init_pg_text_encoder();
	init_pg_text_decoder();
	init_pg_binary_encoder();
	init_pg_binary_decoder();
	init_pg_copycoder();
}
コード例 #16
0
ファイル: ool.c プロジェクト: engineyard/rb-gsl
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);							
}
コード例 #17
0
ファイル: wongi_turtle.c プロジェクト: ulfurinn/wongi-rdf
void define_prelude() {
	mWongi = rb_define_module( "Wongi" );
	mRDF = rb_define_module_under( mWongi, "RDF" );
}
コード例 #18
0
ファイル: curb.c プロジェクト: Datesta/curb
void Init_curb_core() {
  // TODO we need to call curl_global_cleanup at exit!
  curl_version_info_data *ver;
  VALUE curlver, curllongver, curlvernum;

  curl_global_init(CURL_GLOBAL_ALL);
  ver = curl_version_info(CURLVERSION_NOW);

  mCurl = rb_define_module("Curl");

  curlver = rb_str_new2(ver->version);
  curllongver = rb_str_new2(curl_version());
  curlvernum = LONG2NUM(LIBCURL_VERSION_NUM);

  rb_define_const(mCurl, "CURB_VERSION", rb_str_new2(CURB_VERSION));
  rb_define_const(mCurl, "VERSION", curlver);
  rb_define_const(mCurl, "CURL_VERSION", curlver);
  rb_define_const(mCurl, "VERNUM", curlvernum);
  rb_define_const(mCurl, "CURL_VERNUM", curlvernum);
  rb_define_const(mCurl, "LONG_VERSION", curllongver);
  rb_define_const(mCurl, "CURL_LONG_VERSION", curllongver);

  /* Passed to on_debug handler to indicate that the data is informational text. */
  rb_define_const(mCurl, "CURLINFO_TEXT", LONG2NUM(CURLINFO_TEXT));

  /* Passed to on_debug handler to indicate that the data is header (or header-like) data received from the peer. */
  rb_define_const(mCurl, "CURLINFO_HEADER_IN", LONG2NUM(CURLINFO_HEADER_IN));

  /* Passed to on_debug handler to indicate that the data is header (or header-like) data sent to the peer. */
  rb_define_const(mCurl, "CURLINFO_HEADER_OUT", LONG2NUM(CURLINFO_HEADER_OUT));

  /* Passed to on_debug handler to indicate that the data is protocol data received from the peer. */
  rb_define_const(mCurl, "CURLINFO_DATA_IN", LONG2NUM(CURLINFO_DATA_IN));

  /* Passed to on_debug handler to indicate that the data is protocol data sent to the peer. */
  rb_define_const(mCurl, "CURLINFO_DATA_OUT", LONG2NUM(CURLINFO_DATA_OUT));

#ifdef HAVE_CURLFTPMETHOD_MULTICWD 
  rb_define_const(mCurl, "CURL_MULTICWD",  LONG2NUM(CURLFTPMETHOD_MULTICWD));
#endif

#ifdef HAVE_CURLFTPMETHOD_NOCWD 
  rb_define_const(mCurl, "CURL_NOCWD",     LONG2NUM(CURLFTPMETHOD_NOCWD));
#endif

#ifdef HAVE_CURLFTPMETHOD_SINGLECWD 
  rb_define_const(mCurl, "CURL_SINGLECWD", LONG2NUM(CURLFTPMETHOD_SINGLECWD));
#endif

  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is an HTTP proxy. (libcurl >= 7.10) */
#ifdef HAVE_CURLPROXY_HTTP
  rb_define_const(mCurl, "CURLPROXY_HTTP", LONG2NUM(CURLPROXY_HTTP));
#else
  rb_define_const(mCurl, "CURLPROXY_HTTP", LONG2NUM(-1));
#endif

#ifdef CURL_VERSION_SSL
  rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", LONG2NUM(CURL_SSLVERSION_DEFAULT));
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1",   LONG2NUM(CURL_SSLVERSION_TLSv1));
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2",   LONG2NUM(CURL_SSLVERSION_SSLv2));
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3",   LONG2NUM(CURL_SSLVERSION_SSLv3));
#if HAVE_CURL_SSLVERSION_TLSv1_0
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0",   LONG2NUM(CURL_SSLVERSION_TLSv1_0));
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_1
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1",   LONG2NUM(CURL_SSLVERSION_TLSv1_1));
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_2
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2",   LONG2NUM(CURL_SSLVERSION_TLSv1_2));
#endif

  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(CURB_FTPSSL_CONTROL));
  rb_define_const(mCurl, "CURL_USESSL_NONE", LONG2NUM(CURB_FTPSSL_NONE));
  rb_define_const(mCurl, "CURL_USESSL_TRY", LONG2NUM(CURB_FTPSSL_TRY));
  rb_define_const(mCurl, "CURL_USESSL_ALL", LONG2NUM(CURB_FTPSSL_ALL));
#else
  rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1",   LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2",   LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3",   LONG2NUM(-1));
#if HAVE_CURL_SSLVERSION_TLSv1_0
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(-1));
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_1
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(-1));
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_2
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(-1));
#endif

  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_USESSL_NONE", LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_USESSL_TRY", LONG2NUM(-1));
  rb_define_const(mCurl, "CURL_USESSL_ALL", LONG2NUM(-1));
#endif

  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS4 proxy. (libcurl >= 7.15.2) */
#ifdef HAVE_CURLPROXY_SOCKS4
  rb_define_const(mCurl, "CURLPROXY_SOCKS4", LONG2NUM(CURLPROXY_SOCKS4));
#else
  rb_define_const(mCurl, "CURLPROXY_SOCKS4", LONG2NUM(-2));
#endif

  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS4A proxy. (libcurl >= 7.18.0) */
#ifdef HAVE_CURLPROXY_SOCKS4A
  rb_define_const(mCurl, "CURLPROXY_SOCKS4A", LONG2NUM(CURLPROXY_SOCKS4A));
#else
  rb_define_const(mCurl, "CURLPROXY_SOCKS4A", LONG2NUM(-2));
#endif

  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS5 proxy. (libcurl >= 7.10) */
#ifdef HAVE_CURLPROXY_SOCKS5
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", LONG2NUM(CURLPROXY_SOCKS5));
#else
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", LONG2NUM(-2));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Basic authentication. */
#ifdef HAVE_CURLAUTH_BASIC
  rb_define_const(mCurl, "CURLAUTH_BASIC", LONG2NUM(CURLAUTH_BASIC));
#else
  rb_define_const(mCurl, "CURLAUTH_BASIC", LONG2NUM(0));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Digest authentication. */
#ifdef HAVE_CURLAUTH_DIGEST
  rb_define_const(mCurl, "CURLAUTH_DIGEST", LONG2NUM(CURLAUTH_DIGEST));
#else
  rb_define_const(mCurl, "CURLAUTH_DIGEST", LONG2NUM(0));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use GSS Negotiate authentication. Requires a suitable GSS-API library. */
#ifdef HAVE_CURLAUTH_GSSNEGOTIATE
  rb_define_const(mCurl, "CURLAUTH_GSSNEGOTIATE", LONG2NUM(CURLAUTH_GSSNEGOTIATE));
#else
  rb_define_const(mCurl, "CURLAUTH_GSSNEGOTIATE", LONG2NUM(0));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use HTTP NTLM authentication. Requires MS Windows or OpenSSL support. */
#ifdef HAVE_CURLAUTH_NTLM
  rb_define_const(mCurl, "CURLAUTH_NTLM", LONG2NUM(CURLAUTH_NTLM));
#else
  rb_define_const(mCurl, "CURLAUTH_NTLM", LONG2NUM(0));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, allows libcurl to select any suitable authentication method except basic. */
#ifdef HAVE_CURLAUTH_ANYSAFE
  rb_define_const(mCurl, "CURLAUTH_ANYSAFE", LONG2NUM(CURLAUTH_ANYSAFE));
#else
  rb_define_const(mCurl, "CURLAUTH_ANYSAFE", LONG2NUM(0));
#endif

  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, allows libcurl to select any suitable authentication method. */
#ifdef HAVE_CURLAUTH_ANY
  rb_define_const(mCurl, "CURLAUTH_ANY", LONG2NUM(CURLAUTH_ANY));
#else
  rb_define_const(mCurl, "CURLAUTH_ANY", LONG2NUM(0));
#endif

  CURB_DEFINE(CURLOPT_VERBOSE);
  CURB_DEFINE(CURLOPT_HEADER);
  CURB_DEFINE(CURLOPT_NOPROGRESS);
  CURB_DEFINE(CURLOPT_NOSIGNAL);
#if HAVE_CURLOPT_PATH_AS_IS
  CURB_DEFINE(CURLOPT_PATH_AS_IS);
#endif
  CURB_DEFINE(CURLOPT_WRITEFUNCTION);
  CURB_DEFINE(CURLOPT_WRITEDATA);
  CURB_DEFINE(CURLOPT_READFUNCTION);
  CURB_DEFINE(CURLOPT_READDATA);
  CURB_DEFINE(CURLOPT_IOCTLFUNCTION);
  CURB_DEFINE(CURLOPT_IOCTLDATA);
#if HAVE_CURLOPT_SEEKFUNCTION
  CURB_DEFINE(CURLOPT_SEEKFUNCTION);
#endif
#if HAVE_CURLOPT_SEEKDATA
  CURB_DEFINE(CURLOPT_SEEKDATA);
#endif
#if HAVE_CURLOPT_SOCKOPTFUNCTION
  CURB_DEFINE(CURLOPT_SOCKOPTFUNCTION);
#endif
#if HAVE_CURLOPT_SOCKOPTDATA
  CURB_DEFINE(CURLOPT_SOCKOPTDATA);
#endif
#if HAVE_CURLOPT_OPENSOCKETFUNCTION
  CURB_DEFINE(CURLOPT_OPENSOCKETFUNCTION);
#endif
#if HAVE_CURLOPT_OPENSOCKETDATA
  CURB_DEFINE(CURLOPT_OPENSOCKETDATA);
#endif
  CURB_DEFINE(CURLOPT_PROGRESSFUNCTION);
  CURB_DEFINE(CURLOPT_PROGRESSDATA);
  CURB_DEFINE(CURLOPT_HEADERFUNCTION);
  CURB_DEFINE(CURLOPT_WRITEHEADER);
  CURB_DEFINE(CURLOPT_DEBUGFUNCTION);
  CURB_DEFINE(CURLOPT_DEBUGDATA);
  CURB_DEFINE(CURLOPT_SSL_CTX_FUNCTION);
  CURB_DEFINE(CURLOPT_SSL_CTX_DATA);
  CURB_DEFINE(CURLOPT_CONV_TO_NETWORK_FUNCTION);
  CURB_DEFINE(CURLOPT_CONV_FROM_NETWORK_FUNCTION);
  CURB_DEFINE(CURLOPT_CONV_FROM_UTF8_FUNCTION);

#if HAVE_CURLOPT_INTERLEAVEFUNCTION
  CURB_DEFINE(CURLOPT_INTERLEAVEFUNCTION);
#endif
#if HAVE_CURLOPT_INTERLEAVEDATA
  CURB_DEFINE(CURLOPT_INTERLEAVEDATA);
#endif
#if HAVE_CURLOPT_CHUNK_BGN_FUNCTION
  CURB_DEFINE(CURLOPT_CHUNK_BGN_FUNCTION);
#endif
#if HAVE_CURLOPT_CHUNK_END_FUNCTION
  CURB_DEFINE(CURLOPT_CHUNK_END_FUNCTION);
#endif
#if HAVE_CURLOPT_CHUNK_DATA
  CURB_DEFINE(CURLOPT_CHUNK_DATA);
#endif
#if HAVE_CURLOPT_FNMATCH_FUNCTION
  CURB_DEFINE(CURLOPT_FNMATCH_FUNCTION);
#endif
#if HAVE_CURLOPT_FNMATCH_DATA
  CURB_DEFINE(CURLOPT_FNMATCH_DATA);
#endif
#if HAVE_CURLOPT_ERRORBUFFER
  CURB_DEFINE(CURLOPT_ERRORBUFFER);
#endif
#if HAVE_CURLOPT_STDERR
  CURB_DEFINE(CURLOPT_STDERR);
#endif
#if HAVE_CURLOPT_FAILONERROR
  CURB_DEFINE(CURLOPT_FAILONERROR);
#endif
  CURB_DEFINE(CURLOPT_URL);
#if HAVE_CURLOPT_PROTOCOLS
  CURB_DEFINE(CURLOPT_PROTOCOLS);
#endif
#if HAVE_CURLOPT_REDIR_PROTOCOLS
  CURB_DEFINE(CURLOPT_REDIR_PROTOCOLS);
#endif
  CURB_DEFINE(CURLOPT_PROXY);
  CURB_DEFINE(CURLOPT_PROXYPORT);
#if HAVE_CURLOPT_PROXYTYPE
  CURB_DEFINE(CURLOPT_PROXYTYPE);
#endif
#if HAVE_CURLOPT_NOPROXY
  CURB_DEFINE(CURLOPT_NOPROXY);
#endif
  CURB_DEFINE(CURLOPT_HTTPPROXYTUNNEL);
#if HAVE_CURLOPT_SOCKS5_GSSAPI_SERVICE
  CURB_DEFINE(CURLOPT_SOCKS5_GSSAPI_SERVICE);
#endif
#if HAVE_CURLOPT_SOCKS5_GSSAPI_NEC
  CURB_DEFINE(CURLOPT_SOCKS5_GSSAPI_NEC);
#endif
  CURB_DEFINE(CURLOPT_INTERFACE);
#if HAVE_CURLOPT_LOCALPORT
  CURB_DEFINE(CURLOPT_LOCALPORT);
#endif
  CURB_DEFINE(CURLOPT_DNS_CACHE_TIMEOUT);
  CURB_DEFINE(CURLOPT_DNS_USE_GLOBAL_CACHE);
  CURB_DEFINE(CURLOPT_BUFFERSIZE);
  CURB_DEFINE(CURLOPT_PORT);
  CURB_DEFINE(CURLOPT_TCP_NODELAY);
#if HAVE_CURLOPT_ADDRESS_SCOPE
  CURB_DEFINE(CURLOPT_ADDRESS_SCOPE);
#endif
  CURB_DEFINE(CURLOPT_NETRC);
    CURB_DEFINE(CURL_NETRC_OPTIONAL);
    CURB_DEFINE(CURL_NETRC_IGNORED);
    CURB_DEFINE(CURL_NETRC_REQUIRED);
#if HAVE_CURLOPT_NETRC_FILE
  CURB_DEFINE(CURLOPT_NETRC_FILE);
#endif
  CURB_DEFINE(CURLOPT_USERPWD);
  CURB_DEFINE(CURLOPT_PROXYUSERPWD);
#if HAVE_CURLOPT_USERNAME
  CURB_DEFINE(CURLOPT_USERNAME);
#endif
#if HAVE_CURLOPT_PASSWORD
  CURB_DEFINE(CURLOPT_PASSWORD);
#endif
#if HAVE_CURLOPT_PROXYUSERNAME
  CURB_DEFINE(CURLOPT_PASSWORD);
#endif
#if HAVE_CURLOPT_PROXYPASSWORD
  CURB_DEFINE(CURLOPT_PASSWORD);
#endif

#if HAVE_CURLOPT_HTTPAUTH
  CURB_DEFINE(CURLOPT_HTTPAUTH);
#endif
#if HAVE_CURLAUTH_DIGEST_IE
    CURB_DEFINE(CURLAUTH_DIGEST_IE);
#endif
#if HAVE_CURLAUTH_ONLY
    CURB_DEFINE(CURLAUTH_ONLY);
#endif
#if HAVE_CURLOPT_TLSAUTH_TYPE
  CURB_DEFINE(CURLOPT_TLSAUTH_TYPE);
#endif
#if HAVE_CURLOPT_TLSAUTH_SRP
  CURB_DEFINE(CURLOPT_TLSAUTH_SRP);
#endif
#if HAVE_CURLOPT_TLSAUTH_USERNAME
  CURB_DEFINE(CURLOPT_TLSAUTH_USERNAME);
#endif
#if HAVE_CURLOPT_TLSAUTH_PASSWORD
  CURB_DEFINE(CURLOPT_TLSAUTH_PASSWORD);
#endif
#if HAVE_CURLOPT_PROXYAUTH
  CURB_DEFINE(CURLOPT_PROXYAUTH);
#endif
#if HAVE_CURLOPT_AUTOREFERER
  CURB_DEFINE(CURLOPT_AUTOREFERER);
#endif
#if HAVE_CURLOPT_ENCODING
  CURB_DEFINE(CURLOPT_ENCODING);
#endif
#if HAVE_CURLOPT_FOLLOWLOCATION
  CURB_DEFINE(CURLOPT_FOLLOWLOCATION);
#endif
#if HAVE_CURLOPT_UNRESTRICTED_AUTH
  CURB_DEFINE(CURLOPT_UNRESTRICTED_AUTH);
#endif
#if HAVE_CURLOPT_MAXREDIRS
  CURB_DEFINE(CURLOPT_MAXREDIRS);
#endif
#if HAVE_CURLOPT_POSTREDIR
  CURB_DEFINE(CURLOPT_POSTREDIR);
#endif
#if HAVE_CURLOPT_PUT
  CURB_DEFINE(CURLOPT_PUT);
#endif
#if HAVE_CURLOPT_POST
  CURB_DEFINE(CURLOPT_POST);
#endif
  CURB_DEFINE(CURLOPT_POSTFIELDS);
  CURB_DEFINE(CURLOPT_POSTFIELDSIZE);
#if HAVE_CURLOPT_POSTFIELDSIZE_LARGE
  CURB_DEFINE(CURLOPT_POSTFIELDSIZE_LARGE);
#endif
#if HAVE_CURLOPT_COPYPOSTFIELDS
  CURB_DEFINE(CURLOPT_COPYPOSTFIELDS);
#endif
#if HAVE_CURLOPT_HTTPPOST
  CURB_DEFINE(CURLOPT_HTTPPOST);
#endif
  CURB_DEFINE(CURLOPT_REFERER);
  CURB_DEFINE(CURLOPT_USERAGENT);
  CURB_DEFINE(CURLOPT_HTTPHEADER);
#if HAVE_CURLOPT_HTTP200ALIASES
  CURB_DEFINE(CURLOPT_HTTP200ALIASES);
#endif

  CURB_DEFINE(CURLOPT_COOKIE);
  CURB_DEFINE(CURLOPT_COOKIEFILE);
  CURB_DEFINE(CURLOPT_COOKIEJAR);

#if HAVE_CURLOPT_COOKIESESSION
  CURB_DEFINE(CURLOPT_COOKIESESSION);
#endif
#if HAVE_CURLOPT_COOKIELIST
  CURB_DEFINE(CURLOPT_COOKIELIST);
#endif
#if HAVE_CURLOPT_HTTPGET
  CURB_DEFINE(CURLOPT_HTTPGET);
#endif
  CURB_DEFINE(CURLOPT_HTTP_VERSION);
    CURB_DEFINE(CURL_HTTP_VERSION_NONE);
    CURB_DEFINE(CURL_HTTP_VERSION_1_0);
    CURB_DEFINE(CURL_HTTP_VERSION_1_1);
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
    CURB_DEFINE(CURL_HTTP_VERSION_2_0);
#endif
#if HAVE_CURLOPT_IGNORE_CONTENT_LENGTH
  CURB_DEFINE(CURLOPT_IGNORE_CONTENT_LENGTH);
#endif
#if HAVE_CURLOPT_HTTP_CONTENT_DECODING
  CURB_DEFINE(CURLOPT_HTTP_CONTENT_DECODING);
#endif
#if HAVE_CURLOPT_HTTP_TRANSFER_DECODING
  CURB_DEFINE(CURLOPT_HTTP_TRANSFER_DECODING);
#endif
#if HAVE_CURLOPT_MAIL_FROM
  CURB_DEFINE(CURLOPT_MAIL_FROM);
#endif
#if HAVE_CURLOPT_MAIL_RCPT
  CURB_DEFINE(CURLOPT_MAIL_RCPT);
#endif
#if HAVE_CURLOPT_TFTP_BLKSIZE
  CURB_DEFINE(CURLOPT_TFTP_BLKSIZE);
#endif
#if HAVE_CURLOPT_FTPPORT
  CURB_DEFINE(CURLOPT_FTPPORT);
#endif
#if HAVE_CURLOPT_QUOTE
  CURB_DEFINE(CURLOPT_QUOTE);
#endif
#if HAVE_CURLOPT_POSTQUOTE
  CURB_DEFINE(CURLOPT_POSTQUOTE);
#endif
#if HAVE_CURLOPT_PREQUOTE
  CURB_DEFINE(CURLOPT_PREQUOTE);
#endif
#if HAVE_CURLOPT_DIRLISTONLY
  CURB_DEFINE(CURLOPT_DIRLISTONLY);
#endif
#if HAVE_CURLOPT_APPEND
  CURB_DEFINE(CURLOPT_APPEND);
#endif
#if HAVE_CURLOPT_FTP_USE_EPRT
  CURB_DEFINE(CURLOPT_FTP_USE_EPRT);
#endif
#if HAVE_CURLOPT_FTP_USE_EPSV
  CURB_DEFINE(CURLOPT_FTP_USE_EPSV);
#endif
#if HAVE_CURLOPT_FTP_USE_PRET
  CURB_DEFINE(CURLOPT_FTP_USE_PRET);
#endif
#if HAVE_CURLOPT_FTP_CREATE_MISSING_DIRS
  CURB_DEFINE(CURLOPT_FTP_CREATE_MISSING_DIRS);
#endif
#if HAVE_CURLOPT_FTP_RESPONSE_TIMEOUT
  CURB_DEFINE(CURLOPT_FTP_RESPONSE_TIMEOUT);
#endif
#if HAVE_CURLOPT_FTP_ALTERNATIVE_TO_USER
  CURB_DEFINE(CURLOPT_FTP_ALTERNATIVE_TO_USER);
#endif
#if HAVE_CURLOPT_FTP_SKIP_PASV_IP
  CURB_DEFINE(CURLOPT_FTP_SKIP_PASV_IP);
#endif
#if HAVE_CURLOPT_FTPSSLAUTH
  CURB_DEFINE(CURLOPT_FTPSSLAUTH);
#endif
#if HAVE_CURLFTPAUTH_DEFAULT
  CURB_DEFINE(CURLFTPAUTH_DEFAULT);
#endif
#if HAVE_CURLFTPAUTH_SSL
  CURB_DEFINE(CURLFTPAUTH_SSL);
#endif
#if HAVE_CURLFTPAUTH_TLS
  CURB_DEFINE(CURLFTPAUTH_TLS);
#endif
#if HAVE_CURLOPT_FTP_SSL_CCC
  CURB_DEFINE(CURLOPT_FTP_SSL_CCC);
#endif
#if HAVE_CURLFTPSSL_CCC_NONE
  CURB_DEFINE(CURLFTPSSL_CCC_NONE);
#endif
#if HAVE_CURLFTPSSL_CCC_PASSIVE
  CURB_DEFINE(CURLFTPSSL_CCC_PASSIVE);
#endif
#if HAVE_CURLFTPSSL_CCC_ACTIVE
  CURB_DEFINE(CURLFTPSSL_CCC_ACTIVE);
#endif
#if HAVE_CURLOPT_FTP_ACCOUNT
  CURB_DEFINE(CURLOPT_FTP_ACCOUNT);
#endif
#if HAVE_CURLOPT_FTP_FILEMETHOD
  CURB_DEFINE(CURLOPT_FTP_FILEMETHOD);
#endif
#if HAVE_CURLFTPMETHOD_MULTICWD
  CURB_DEFINE(CURLFTPMETHOD_MULTICWD);
#endif
#if HAVE_CURLFTPMETHOD_NOCWD
  CURB_DEFINE(CURLFTPMETHOD_NOCWD);
#endif
#if HAVE_CURLFTPMETHOD_SINGLECWD
  CURB_DEFINE(CURLFTPMETHOD_SINGLECWD);
#endif
#if HAVE_CURLOPT_RTSP_REQUEST
  CURB_DEFINE(CURLOPT_RTSP_REQUEST);
#endif
#if HAVE_CURL_RTSPREQ_OPTIONS
  CURB_DEFINE(CURL_RTSPREQ_OPTIONS);
#endif
#if HAVE_CURL_RTSPREQ_DESCRIBE
  CURB_DEFINE(CURL_RTSPREQ_DESCRIBE);
#endif
#if HAVE_CURL_RTSPREQ_ANNOUNCE
  CURB_DEFINE(CURL_RTSPREQ_ANNOUNCE);
#endif
#if HAVE_CURL_RTSPREQ_SETUP
  CURB_DEFINE(CURL_RTSPREQ_SETUP);
#endif
#if HAVE_CURL_RTSPREQ_PLAY
  CURB_DEFINE(CURL_RTSPREQ_PLAY);
#endif
#if HAVE_CURL_RTSPREQ_PAUSE
  CURB_DEFINE(CURL_RTSPREQ_PAUSE);
#endif
#if HAVE_CURL_RTSPREQ_TEARDOWN
  CURB_DEFINE(CURL_RTSPREQ_TEARDOWN);
#endif
#if HAVE_CURL_RTSPREQ_GET_PARAMETER
  CURB_DEFINE(CURL_RTSPREQ_GET_PARAMETER);
#endif
#if HAVE_CURL_RTSPREQ_SET_PARAMETER
  CURB_DEFINE(CURL_RTSPREQ_SET_PARAMETER);
#endif
#if HAVE_CURL_RTSPREQ_RECORD
  CURB_DEFINE(CURL_RTSPREQ_RECORD);
#endif
#if HAVE_CURL_RTSPREQ_RECEIVE
  CURB_DEFINE(CURL_RTSPREQ_RECEIVE);
#endif
#if HAVE_CURLOPT_RTSP_SESSION_ID
  CURB_DEFINE(CURLOPT_RTSP_SESSION_ID);
#endif
#if HAVE_CURLOPT_RTSP_STREAM_URI
  CURB_DEFINE(CURLOPT_RTSP_STREAM_URI);
#endif
#if HAVE_CURLOPT_RTSP_TRANSPORT
  CURB_DEFINE(CURLOPT_RTSP_TRANSPORT);
#endif
#if HAVE_CURLOPT_RTSP_HEADER
  CURB_DEFINE(CURLOPT_RTSP_HEADER);
#endif
#if HAVE_CURLOPT_RTSP_CLIENT_CSEQ
  CURB_DEFINE(CURLOPT_RTSP_CLIENT_CSEQ);
#endif
#if HAVE_CURLOPT_RTSP_SERVER_CSEQ
  CURB_DEFINE(CURLOPT_RTSP_SERVER_CSEQ);
#endif

  CURB_DEFINE(CURLOPT_TRANSFERTEXT);
#if HAVE_CURLOPT_PROXY_TRANSFER_MODE
  CURB_DEFINE(CURLOPT_PROXY_TRANSFER_MODE);
#endif
#if HAVE_CURLOPT_CRLF
  CURB_DEFINE(CURLOPT_CRLF);
#endif
#if HAVE_CURLOPT_RANGE
  CURB_DEFINE(CURLOPT_RANGE);
#endif
#if HAVE_CURLOPT_RESUME_FROM
  CURB_DEFINE(CURLOPT_RESUME_FROM);
#endif
#if HAVE_CURLOPT_RESUME_FROM_LARGE
  CURB_DEFINE(CURLOPT_RESUME_FROM_LARGE);
#endif
#if HAVE_CURLOPT_CUSTOMREQUEST
  CURB_DEFINE(CURLOPT_CUSTOMREQUEST);
#endif
#if HAVE_CURLOPT_FILETIME
  CURB_DEFINE(CURLOPT_FILETIME);
#endif
#if HAVE_CURLOPT_NOBODY
  CURB_DEFINE(CURLOPT_NOBODY);
#endif
#if HAVE_CURLOPT_INFILESIZE
  CURB_DEFINE(CURLOPT_INFILESIZE);
#endif
#if HAVE_CURLOPT_INFILESIZE_LARGE
  CURB_DEFINE(CURLOPT_INFILESIZE_LARGE);
#endif
#if HAVE_CURLOPT_UPLOAD
  CURB_DEFINE(CURLOPT_UPLOAD);
#endif
#if HAVE_CURLOPT_MAXFILESIZE
  CURB_DEFINE(CURLOPT_MAXFILESIZE);
#endif
#if HAVE_CURLOPT_MAXFILESIZE_LARGE
  CURB_DEFINE(CURLOPT_MAXFILESIZE_LARGE);
#endif
#if HAVE_CURLOPT_TIMECONDITION
  CURB_DEFINE(CURLOPT_TIMECONDITION);
#endif
#if HAVE_CURLOPT_TIMEVALUE
  CURB_DEFINE(CURLOPT_TIMEVALUE);
#endif

#if HAVE_CURLOPT_TIMEOUT
  CURB_DEFINE(CURLOPT_TIMEOUT);
#endif
#if HAVE_CURLOPT_TIMEOUT_MS
  CURB_DEFINE(CURLOPT_TIMEOUT_MS);
#endif
#if HAVE_CURLOPT_LOW_SPEED_LIMIT
  CURB_DEFINE(CURLOPT_LOW_SPEED_LIMIT);
#endif
#if HAVE_CURLOPT_LOW_SPEED_TIME
  CURB_DEFINE(CURLOPT_LOW_SPEED_TIME);
#endif
#if HAVE_CURLOPT_MAX_SEND_SPEED_LARGE
  CURB_DEFINE(CURLOPT_MAX_SEND_SPEED_LARGE);
#endif
#if HAVE_CURLOPT_MAX_RECV_SPEED_LARGE
  CURB_DEFINE(CURLOPT_MAX_RECV_SPEED_LARGE);
#endif
#if HAVE_CURLOPT_MAXCONNECTS
  CURB_DEFINE(CURLOPT_MAXCONNECTS);
#endif
#if HAVE_CURLOPT_CLOSEPOLICY
  CURB_DEFINE(CURLOPT_CLOSEPOLICY);
#endif
#if HAVE_CURLOPT_FRESH_CONNECT
  CURB_DEFINE(CURLOPT_FRESH_CONNECT);
#endif
#if HAVE_CURLOPT_FORBID_REUSE
  CURB_DEFINE(CURLOPT_FORBID_REUSE);
#endif
#if HAVE_CURLOPT_CONNECTTIMEOUT
  CURB_DEFINE(CURLOPT_CONNECTTIMEOUT);
#endif
#if HAVE_CURLOPT_CONNECTTIMEOUT_MS
  CURB_DEFINE(CURLOPT_CONNECTTIMEOUT_MS);
#endif
#if HAVE_CURLOPT_IPRESOLVE
  CURB_DEFINE(CURLOPT_IPRESOLVE);
#endif
#if HAVE_CURL_IPRESOLVE_WHATEVER
  CURB_DEFINE(CURL_IPRESOLVE_WHATEVER);
#endif
#if HAVE_CURL_IPRESOLVE_V4
  CURB_DEFINE(CURL_IPRESOLVE_V4);
#endif
#if HAVE_CURL_IPRESOLVE_V6
  CURB_DEFINE(CURL_IPRESOLVE_V6);
#endif
#if HAVE_CURLOPT_CONNECT_ONLY
  CURB_DEFINE(CURLOPT_CONNECT_ONLY);
#endif
#if HAVE_CURLOPT_USE_SSL
  CURB_DEFINE(CURLOPT_USE_SSL);
#endif
#if HAVE_CURLUSESSL_NONE
  CURB_DEFINE(CURLUSESSL_NONE);
#endif
#if HAVE_CURLUSESSL_TRY
  CURB_DEFINE(CURLUSESSL_TRY);
#endif
#if HAVE_CURLUSESSL_CONTROL
  CURB_DEFINE(CURLUSESSL_CONTROL);
#endif
#if HAVE_CURLUSESSL_ALL
  CURB_DEFINE(CURLUSESSL_ALL);
#endif
#if HAVE_CURLOPT_RESOLVE
  CURB_DEFINE(CURLOPT_RESOLVE);
#endif

#if HAVE_CURLOPT_SSLCERT
  CURB_DEFINE(CURLOPT_SSLCERT);
#endif
#if HAVE_CURLOPT_SSLCERTTYPE
  CURB_DEFINE(CURLOPT_SSLCERTTYPE);
#endif
#if HAVE_CURLOPT_SSLKEY
  CURB_DEFINE(CURLOPT_SSLKEY);
#endif
#if HAVE_CURLOPT_SSLKEYTYPE
  CURB_DEFINE(CURLOPT_SSLKEYTYPE);
#endif
#if HAVE_CURLOPT_KEYPASSWD
  CURB_DEFINE(CURLOPT_KEYPASSWD);
#endif
#if HAVE_CURLOPT_SSLENGINE
  CURB_DEFINE(CURLOPT_SSLENGINE);
#endif
#if HAVE_CURLOPT_SSLENGINE_DEFAULT
  CURB_DEFINE(CURLOPT_SSLENGINE_DEFAULT);
#endif
#if HAVE_CURLOPT_SSLVERSION
  CURB_DEFINE(CURLOPT_SSLVERSION);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1
  CURB_DEFINE(CURL_SSLVERSION_TLSv1);
#endif
#if HAVE_CURL_SSLVERSION_SSLv2
  CURB_DEFINE(CURL_SSLVERSION_SSLv2);
#endif
#if HAVE_CURL_SSLVERSION_SSLv3
  CURB_DEFINE(CURL_SSLVERSION_SSLv3);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_0
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_0);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_1
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_1);
#endif
#if HAVE_CURL_SSLVERSION_TLSv1_2
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_2);
#endif
#if HAVE_CURLOPT_SSL_VERIFYPEER
  CURB_DEFINE(CURLOPT_SSL_VERIFYPEER);
#endif
#if HAVE_CURLOPT_CAINFO
  CURB_DEFINE(CURLOPT_CAINFO);
#endif
#if HAVE_CURLOPT_ISSUERCERT
  CURB_DEFINE(CURLOPT_ISSUERCERT);
#endif
#if HAVE_CURLOPT_CAPATH
  CURB_DEFINE(CURLOPT_CAPATH);
#endif
#if HAVE_CURLOPT_CRLFILE
  CURB_DEFINE(CURLOPT_CRLFILE);
#endif
#if HAVE_CURLOPT_SSL_VERIFYHOST
  CURB_DEFINE(CURLOPT_SSL_VERIFYHOST);
#endif
#if HAVE_CURLOPT_CERTINFO
  CURB_DEFINE(CURLOPT_CERTINFO);
#endif
#if HAVE_CURLOPT_RANDOM_FILE
  CURB_DEFINE(CURLOPT_RANDOM_FILE);
#endif
#if HAVE_CURLOPT_EGDSOCKET
  CURB_DEFINE(CURLOPT_EGDSOCKET);
#endif
#if HAVE_CURLOPT_SSL_CIPHER_LIST
  CURB_DEFINE(CURLOPT_SSL_CIPHER_LIST);
#endif
#if HAVE_CURLOPT_SSL_SESSIONID_CACHE
  CURB_DEFINE(CURLOPT_SSL_SESSIONID_CACHE);
#endif
#if HAVE_CURLOPT_KRBLEVEL
  CURB_DEFINE(CURLOPT_KRBLEVEL);
#endif

#if HAVE_CURLOPT_SSH_AUTH_TYPES
  CURB_DEFINE(CURLOPT_SSH_AUTH_TYPES);
#endif
#if HAVE_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
  CURB_DEFINE(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
#endif
#if HAVE_CURLOPT_SSH_PUBLIC_KEYFILE
  CURB_DEFINE(CURLOPT_SSH_PUBLIC_KEYFILE);
#endif
#if HAVE_CURLOPT_SSH_PRIVATE_KEYFILE
  CURB_DEFINE(CURLOPT_SSH_PRIVATE_KEYFILE);
#endif
#if HAVE_CURLOPT_SSH_KNOWNHOSTS
  CURB_DEFINE(CURLOPT_SSH_KNOWNHOSTS);
#endif
#if HAVE_CURLOPT_SSH_KEYFUNCTION
  CURB_DEFINE(CURLOPT_SSH_KEYFUNCTION);
#endif
#if HAVE_CURLKHSTAT_FINE_ADD_TO_FILE
  CURB_DEFINE(CURLKHSTAT_FINE_ADD_TO_FILE);
#endif
#if HAVE_CURLKHSTAT_FINE
  CURB_DEFINE(CURLKHSTAT_FINE);
#endif
#if HAVE_CURLKHSTAT_REJECT
  CURB_DEFINE(CURLKHSTAT_REJECT);
#endif
#if HAVE_CURLKHSTAT_DEFER
  CURB_DEFINE(CURLKHSTAT_DEFER);
#endif
#if HAVE_CURLOPT_SSH_KEYDATA
  CURB_DEFINE(CURLOPT_SSH_KEYDATA);
#endif

#if HAVE_CURLOPT_PRIVATE
  CURB_DEFINE(CURLOPT_PRIVATE);
#endif
#if HAVE_CURLOPT_SHARE
  CURB_DEFINE(CURLOPT_SHARE);
#endif
#if HAVE_CURLOPT_NEW_FILE_PERMS
  CURB_DEFINE(CURLOPT_NEW_FILE_PERMS);
#endif
#if HAVE_CURLOPT_NEW_DIRECTORY_PERMS
  CURB_DEFINE(CURLOPT_NEW_DIRECTORY_PERMS);
#endif

#if HAVE_CURLOPT_TELNETOPTIONS
  CURB_DEFINE(CURLOPT_TELNETOPTIONS);
#endif

#if HAVE_CURLOPT_GSSAPI_DELEGATION
  CURB_DEFINE(CURLOPT_GSSAPI_DELEGATION);
#endif

#if HAVE_CURLGSSAPI_DELEGATION_FLAG
  CURB_DEFINE(CURLGSSAPI_DELEGATION_FLAG);
#endif

#if HAVE_CURLGSSAPI_DELEGATION_POLICY_FLAG
  CURB_DEFINE(CURLGSSAPI_DELEGATION_POLICY_FLAG);
#endif

#if HAVE_CURLOPT_UNIX_SOCKET_PATH
  CURB_DEFINE(CURLOPT_UNIX_SOCKET_PATH);
#endif

#if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
  CURB_DEFINE(CURLPIPE_NOTHING);
  CURB_DEFINE(CURLPIPE_HTTP1);
  CURB_DEFINE(CURLPIPE_MULTIPLEX);

  rb_define_const(mCurl, "PIPE_NOTHING", LONG2NUM(CURLPIPE_NOTHING));
  rb_define_const(mCurl, "PIPE_HTTP1", LONG2NUM(CURLPIPE_HTTP1));
  rb_define_const(mCurl, "PIPE_MULTIPLEX", LONG2NUM(CURLPIPE_MULTIPLEX));
#endif

#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
  rb_define_const(mCurl, "HTTP_2_0", LONG2NUM(CURL_HTTP_VERSION_2_0));
#endif
  rb_define_const(mCurl, "HTTP_1_1", LONG2NUM(CURL_HTTP_VERSION_1_1));
  rb_define_const(mCurl, "HTTP_1_0", LONG2NUM(CURL_HTTP_VERSION_1_0));
  rb_define_const(mCurl, "HTTP_NONE", LONG2NUM(CURL_HTTP_VERSION_NONE));



  rb_define_singleton_method(mCurl, "ipv6?", ruby_curl_ipv6_q, 0);
  rb_define_singleton_method(mCurl, "kerberos4?", ruby_curl_kerberos4_q, 0);
  rb_define_singleton_method(mCurl, "ssl?", ruby_curl_ssl_q, 0);
  rb_define_singleton_method(mCurl, "libz?", ruby_curl_libz_q, 0);
  rb_define_singleton_method(mCurl, "ntlm?", ruby_curl_ntlm_q, 0);
  rb_define_singleton_method(mCurl, "gssnegotiate?", ruby_curl_gssnegotiate_q, 0);
  rb_define_singleton_method(mCurl, "debug?", ruby_curl_debug_q, 0);
  rb_define_singleton_method(mCurl, "asyncdns?", ruby_curl_asyncdns_q, 0);
  rb_define_singleton_method(mCurl, "spnego?", ruby_curl_spnego_q, 0);
  rb_define_singleton_method(mCurl, "largefile?", ruby_curl_largefile_q, 0);
  rb_define_singleton_method(mCurl, "idn?", ruby_curl_idn_q, 0);
  rb_define_singleton_method(mCurl, "sspi?", ruby_curl_sspi_q, 0);
  rb_define_singleton_method(mCurl, "conv?", ruby_curl_conv_q, 0);
  rb_define_singleton_method(mCurl, "http2?", ruby_curl_http2_q, 0);

  init_curb_errors();
  init_curb_easy();
  init_curb_postfield();
  init_curb_multi();
  init_curb_upload();
}
コード例 #19
0
ファイル: rpam.c プロジェクト: bias/rpam
/* initialize */
void Init_rpam() {
    Rpam = rb_define_module("Rpam");
    rb_define_method(Rpam, "authpam", method_authpam, 2);
}
コード例 #20
0
ファイル: ruby_xml_schema.c プロジェクト: joevandyk/merb-gems
#include "ruby_libxml.h"
#include "ruby_xml_schema.h"

VALUE cXMLSchema;

// Rdoc needs to know 
#ifdef RDOC_NEVER_DEFINED
  mLibXML = rb_define_module("LibXML");
  mXML = rb_define_module_under(mLibXML, "XML");
#endif

static void
ruby_xml_schema_mark(ruby_xml_schema *rxschema) {
  return;
}

void
ruby_xml_schema_free(ruby_xml_schema *rxschema) {
  if (rxschema->schema != NULL) {
    xmlSchemaFree(rxschema->schema);
    rxschema->schema = NULL;
  }

  ruby_xfree(rxschema);
}

/*
 * call-seq:
 *    XML::Schema.new(schema_uri) -> schema
 * 
 * Create a new schema from the specified URI.
コード例 #21
0
ファイル: rkerberos.c プロジェクト: brandonweeks/rkerberos
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();
}
コード例 #22
0
ファイル: ruby_krb5_auth.c プロジェクト: chrismoos/krb5-auth
/*
 * = 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"));
}
コード例 #23
0
ファイル: ossl_ssl.c プロジェクト: DocPsy/MacRuby
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();
}
コード例 #24
0
ファイル: hamming_window.c プロジェクト: hmoody87/noyes
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);
}
コード例 #25
0
ファイル: rudl.c プロジェクト: matozoid/rudl
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();
コード例 #26
0
ファイル: generator.c プロジェクト: imageoptimiser/json
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;
}
コード例 #27
0
ファイル: rbpoppler.c プロジェクト: fukuchi/ruby-gnome2
void
Init_poppler(void)
{
    VALUE RG_TARGET_NAMESPACE;

    RG_TARGET_NAMESPACE = rb_define_module("Poppler");

    rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION",
                    rb_ary_new3(3,
                                INT2FIX(POPPLER_MAJOR_VERSION),
                                INT2FIX(POPPLER_MINOR_VERSION),
                                INT2FIX(POPPLER_MICRO_VERSION)));

    G_DEF_CLASS(POPPLER_TYPE_ERROR, "Error", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_ORIENTATION, "Orientation", RG_TARGET_NAMESPACE);

    G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_TYPE,
                "PageTransitionType", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_ALIGNMENT,
                "PageTransitionAlignment", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_DIRECTION,
                "PageTransitionDirection", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_SELECTION_STYLE, "SelectionStyle", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_FORM_BUTTON_TYPE, "FormButtonType", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_FORM_TEXT_TYPE, "FormTextType", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_FORM_CHOICE_TYPE, "FormChoiceType", RG_TARGET_NAMESPACE);

    G_RENAME_NICK("3D", "TYPE_3D");
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_TYPE, "AnnotationType", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_FLAG, "AnnotationFlag", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE,
        "AnnotationMarkupReplyType", RG_TARGET_NAMESPACE);
    G_RENAME_NICK("3D", "TYPE_3D");
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_EXTERNAL_DATA_TYPE,
        "AnnotationExternalDataType", RG_TARGET_NAMESPACE);
#  if !POPPLER_CHECK_VERSION(0, 9, 0)
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_ICON, "AnnotationTextIcon", RG_TARGET_NAMESPACE);
#  endif
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_STATE, "AnnotationTextState", RG_TARGET_NAMESPACE);
    G_DEF_CLASS(POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING,
        "AnnotationFreeTextQuadding", RG_TARGET_NAMESPACE);

    G_DEF_CLASS(POPPLER_TYPE_BACKEND, "Backend", RG_TARGET_NAMESPACE);

    RG_DEF_SMETHOD(backend, 0);
    RG_DEF_SMETHOD(version, 0);
    RG_DEF_SMETHOD_P(cairo_available, 0);

    Init_poppler_indexiter(RG_TARGET_NAMESPACE);
    Init_poppler_fontinfo(RG_TARGET_NAMESPACE);
    Init_poppler_document(RG_TARGET_NAMESPACE);
    Init_poppler_fontsiter(RG_TARGET_NAMESPACE);
    Init_poppler_psfile(RG_TARGET_NAMESPACE);
    Init_poppler_rectangle(RG_TARGET_NAMESPACE);
    Init_poppler_page(RG_TARGET_NAMESPACE);
    Init_poppler_color(RG_TARGET_NAMESPACE);
    Init_poppler_linkmapping(RG_TARGET_NAMESPACE);
    Init_poppler_pagetransition(RG_TARGET_NAMESPACE);
    Init_poppler_imagemapping(RG_TARGET_NAMESPACE);
    Init_poppler_formfieldmapping(RG_TARGET_NAMESPACE);
    Init_poppler_annotationmapping(RG_TARGET_NAMESPACE);
    Init_poppler_attachment(RG_TARGET_NAMESPACE);
    Init_poppler_action(RG_TARGET_NAMESPACE);
    Init_poppler_annotation(RG_TARGET_NAMESPACE);
    Init_poppler_annotationmarkup(RG_TARGET_NAMESPACE);
    Init_poppler_annotationtext(RG_TARGET_NAMESPACE);
    Init_poppler_annotationfreetext(RG_TARGET_NAMESPACE);
    Init_poppler_annotationcalloutline(RG_TARGET_NAMESPACE);
    Init_poppler_form_field(RG_TARGET_NAMESPACE);
}
コード例 #28
0
ファイル: generator.c プロジェクト: AdamDotCom/my-rvm
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");
}
コード例 #29
0
void
Init_extreme_timeout(void)
{
    VALUE module = rb_define_module("ExtremeTimeout");
    rb_define_module_function(module, "timeout", timeout, -1);
}
コード例 #30
0
ファイル: webkit.c プロジェクト: rubiojr/gtk-webkit-ruby
/* Init */
void
Init_webkit(void)
{
  mWebKit = rb_define_module("WebKit");
  rb_define_singleton_method(mWebKit, "set_web_database_path", WebKit_CLASS_set_web_database_path, 1);
  rb_define_singleton_method(mWebKit, "remove_all_web_databases", WebKit_CLASS_remove_all_web_databases, 0);
  rb_define_singleton_method(mWebKit, "set_default_web_database_quota", WebKit_CLASS_set_default_web_database_quota, 1);
  cJsPtr = rb_define_class_under(mWebKit, "JsPtr", rb_cObject);
  cJavascriptError = rb_define_class_under(mWebKit, "JavascriptError", rb_eStandardError);
  cWebSettings = G_DEF_CLASS(WEBKIT_TYPE_WEB_SETTINGS, "WebSettings", mWebKit);
  rb_define_method(cWebSettings, "initialize", WebSettings_initialize, 0);
  cWebPolicyDecision = G_DEF_CLASS(WEBKIT_TYPE_WEB_POLICY_DECISION, "WebPolicyDecision", mWebKit);
  rb_define_method(cWebPolicyDecision, "download", WebPolicyDecision_download, 0);
  rb_define_method(cWebPolicyDecision, "use", WebPolicyDecision_use, 0);
  rb_define_method(cWebPolicyDecision, "ignore", WebPolicyDecision_ignore, 0);
  cWebFrame = G_DEF_CLASS(WEBKIT_TYPE_WEB_FRAME, "WebFrame", mWebKit);
  rb_define_method(cWebFrame, "exec_js", WebFrame_exec_js, 1);
  rb_define_method(cWebFrame, "add_ruby_class", WebFrame_add_ruby_class, 2);
  rb_define_method(cWebFrame, "add_ruby_eval", WebFrame_add_ruby_eval, 0);
  rb_define_method(cWebFrame, "add_js_api", WebFrame_add_js_api, 1);
  rb_define_method(cWebFrame, "load_string", WebFrame_load_string, 4);
  cWebView = G_DEF_CLASS(WEBKIT_TYPE_WEB_VIEW, "WebView", mWebKit);
  rb_define_method(cWebView, "initialize", WebView_initialize, 0);
  rb_define_method(cWebView, "open", WebView_open, 1);
  rb_define_method(cWebView, "execute_script", WebView_execute_script, 1);
  rb_define_method(cWebView, "set_settings", WebView_set_settings, 1);
  rb_define_method(cWebView, "load_string", WebView_load_string, 4);
  rb_define_method(cWebView, "load_uri", WebView_load_uri, 1);
  rb_define_method(cWebView, "main_frame", WebView_main_frame, 0);
  rb_define_method(cWebView, "focused_frame", WebView_focused_frame, 0);
  rb_define_method(cWebView, "progress", WebView_progress, 0);
  rb_define_method(cWebView, "title", WebView_title, 0);
  rb_define_method(cWebView, "uri", WebView_uri, 0);
  rb_define_method(cWebView, "reload", WebView_reload, 0);
  rb_define_method(cWebView, "reload_bypass_cache", WebView_reload_bypass_cache, 0);
  rb_define_method(cWebView, "set_custom_encoding", WebView_set_custom_encoding, 1);
  rb_define_method(cWebView, "stop_loading", WebView_stop_loading, 0);
  rb_define_method(cWebView, "has_selection?", WebView_has_selection_query, 0);
  rb_define_method(cWebView, "inspector", WebView_inspector, 0);
  cWebInspector = G_DEF_CLASS(WEBKIT_TYPE_WEB_INSPECTOR, "WebInspector", mWebKit);
  rb_define_method(cWebInspector, "inspect_coordinates", WebInspector_inspect_coordinates, 2);
  rb_define_method(cWebInspector, "uri", WebInspector_uri, 0);
  rb_define_method(cWebInspector, "show", WebInspector_show, 0);
  rb_define_method(cWebInspector, "close", WebInspector_close, 0);
  rb_define_method(cWebInspector, "view", WebInspector_view, 0);
  cWebResource = G_DEF_CLASS(WEBKIT_TYPE_WEB_RESOURCE, "WebResource", mWebKit);
  rb_define_method(cWebResource, "encoding", WebResource_encoding, 0);
  rb_define_method(cWebResource, "frame_name", WebResource_frame_name, 0);
  rb_define_method(cWebResource, "mime_type", WebResource_mime_type, 0);
  rb_define_method(cWebResource, "uri", WebResource_uri, 0);
  rb_define_method(cWebResource, "data", WebResource_data, 0);
  rb_define_method(cWebResource, "data=", WebResource_data_equals, 1);
  cWebNetworkRequest = G_DEF_CLASS(WEBKIT_TYPE_NETWORK_REQUEST, "WebNetworkRequest", mWebKit);
  rb_define_method(cWebNetworkRequest, "uri", WebNetworkRequest_uri, 0);
  rb_define_method(cWebNetworkRequest, "uri=", WebNetworkRequest_uri_equals, 1);
  rb_define_method(cWebNetworkRequest, "message", WebNetworkRequest_message, 0);
  cWebNetworkResponse = G_DEF_CLASS(WEBKIT_TYPE_NETWORK_RESPONSE, "WebNetworkResponse", mWebKit);
  rb_define_method(cWebNetworkResponse, "uri", WebNetworkResponse_uri, 0);
  rb_define_method(cWebNetworkResponse, "uri=", WebNetworkResponse_uri_equals, 1);
  rb_define_method(cWebNetworkResponse, "message", WebNetworkResponse_message, 0);
  cDownload = G_DEF_CLASS(WEBKIT_TYPE_DOWNLOAD, "Download", mWebKit);
  rb_define_method(cDownload, "initialize", Download_initialize, 1);
  rb_define_method(cDownload, "start", Download_start, 0);
  rb_define_method(cDownload, "cancel", Download_cancel, 0);
  rb_define_method(cDownload, "progress", Download_progress, 0);
  rb_define_method(cDownload, "current_size", Download_current_size, 0);
  rb_define_method(cDownload, "total_size", Download_total_size, 0);
  rb_define_method(cDownload, "uri", Download_uri, 0);
  rb_define_method(cDownload, "suggested_filename", Download_suggested_filename, 0);
  genumTargetInfo = G_DEF_CLASS(WEBKIT_TYPE_WEB_VIEW_TARGET_INFO, "TargetInfo", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_WEB_VIEW_TARGET_INFO, "WEBKIT_");
  genumDownloadStatus = G_DEF_CLASS(WEBKIT_TYPE_DOWNLOAD_STATUS, "DownloadStatus", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_DOWNLOAD_STATUS, "WEBKIT_");
  genumDownloadError = G_DEF_CLASS(WEBKIT_TYPE_DOWNLOAD_ERROR, "DownloadError", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_DOWNLOAD_ERROR, "WEBKIT_");
  genumNetworkError = G_DEF_CLASS(WEBKIT_TYPE_NETWORK_ERROR, "NetworkError", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_NETWORK_ERROR, "WEBKIT_");
  genumPolicyError = G_DEF_CLASS(WEBKIT_TYPE_POLICY_ERROR, "PolicyError", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_POLICY_ERROR, "WEBKIT_");
  genumPluginError = G_DEF_CLASS(WEBKIT_TYPE_PLUGIN_ERROR, "PluginError", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_PLUGIN_ERROR, "WEBKIT_");
  genumCacheModel = G_DEF_CLASS(WEBKIT_TYPE_CACHE_MODEL, "CacheModel", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_CACHE_MODEL, "WEBKIT_");
  genumLoadStatus = G_DEF_CLASS(WEBKIT_TYPE_LOAD_STATUS, "LoadStatus", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_LOAD_STATUS, "WEBKIT_");
  genumNavigationReason = G_DEF_CLASS(WEBKIT_TYPE_WEB_NAVIGATION_REASON, "NavigationReason", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_WEB_NAVIGATION_REASON, "WEBKIT_");
  genumHitTestResultContext = G_DEF_CLASS(WEBKIT_TYPE_HIT_TEST_RESULT_CONTEXT, "HitTestResultContext", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_HIT_TEST_RESULT_CONTEXT, "WEBKIT_");
  genumEditingBehavior = G_DEF_CLASS(WEBKIT_TYPE_EDITING_BEHAVIOR, "EditingBehavior", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_EDITING_BEHAVIOR, "WEBKIT_");
  genumNavigationResponse = G_DEF_CLASS(WEBKIT_TYPE_NAVIGATION_RESPONSE, "NavigationResponse", mWebKit);
  G_DEF_CONSTANTS(mWebKit, WEBKIT_TYPE_NAVIGATION_RESPONSE, "WEBKIT_");
rb_gc_register_address(&_gcpool_RubyFunc);
}