Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# version.c

Go to the documentation of this file.

    00001 /**********************************************************************
    00002
    00003   version.c -
    00004
    00005   $Author: nobu $
    00006   created at: Thu Sep 30 20:08:01 JST 1993
    00007
    00008   Copyright (C) 1993-2007 Yukihiro Matsumoto
    00009
    00010 **********************************************************************/
    00011
    00012 #include "ruby/ruby.h"
    00013 #include "version.h"
    00014 #include <stdio.h>
    00015
    00016 #define PRINT(type) puts(ruby_##type)
    00017 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
    00018
    00019 #ifndef RUBY_ARCH
    00020 #define RUBY_ARCH RUBY_PLATFORM
    00021 #endif
    00022 #ifndef RUBY_SITEARCH
    00023 #define RUBY_SITEARCH RUBY_ARCH
    00024 #endif
    00025 #ifdef RUBY_PLATFORM_CPU
    00026 #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
    00027 #endif
    00028 #ifndef RUBY_LIB_PREFIX
    00029 #ifndef RUBY_EXEC_PREFIX
    00030 #error RUBY_EXEC_PREFIX must be defined
    00031 #endif
    00032 #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby"
    00033 #endif
    00034 #ifndef RUBY_SITE_LIB
    00035 #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby"
    00036 #endif
    00037 #ifndef RUBY_VENDOR_LIB
    00038 #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
    00039 #endif
    00040
    00041 #define RUBY_LIB                    RUBY_LIB_PREFIX  "/"RUBY_LIB_VERSION
    00042 #define RUBY_SITE_LIB2              RUBY_SITE_LIB    "/"RUBY_LIB_VERSION
    00043 #define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB  "/"RUBY_LIB_VERSION
    00044 #define RUBY_ARCHLIB                RUBY_LIB         "/"RUBY_ARCH
    00045 #define RUBY_SITE_ARCHLIB           RUBY_SITE_LIB2   "/"RUBY_SITEARCH
    00046 #define RUBY_VENDOR_ARCHLIB         RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
    00047 #ifdef  RUBY_THINARCH
    00048 #define RUBY_THIN_ARCHLIB           RUBY_LIB         "/"RUBY_THINARCH
    00049 #define RUBY_SITE_THIN_ARCHLIB      RUBY_SITE_LIB2   "/"RUBY_THINARCH
    00050 #define RUBY_VENDOR_THIN_ARCHLIB    RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
    00051 #endif
    00052
    00053 const char ruby_version[] = RUBY_VERSION;
    00054 const char ruby_release_date[] = RUBY_RELEASE_DATE;
    00055 const char ruby_platform[] = RUBY_PLATFORM;
    00056 const int ruby_patchlevel = RUBY_PATCHLEVEL;
    00057 const char ruby_description[] = RUBY_DESCRIPTION;
    00058 const char ruby_copyright[] = RUBY_COPYRIGHT;
    00059 const char ruby_engine[] = "ruby";
    00060 VALUE ruby_engine_name = Qnil;
    00061
    00062 const char ruby_initial_load_paths[] =
    00063 #ifndef NO_INITIAL_LOAD_PATH
    00064 #ifdef RUBY_SEARCH_PATH
    00065     RUBY_SEARCH_PATH "\0"
    00066 #endif
    00067     RUBY_SITE_LIB2 "\0"
    00068 #ifdef RUBY_SITE_THIN_ARCHLIB
    00069     RUBY_SITE_THIN_ARCHLIB "\0"
    00070 #endif
    00071     RUBY_SITE_ARCHLIB "\0"
    00072     RUBY_SITE_LIB "\0"
    00073
    00074     RUBY_VENDOR_LIB2 "\0"
    00075 #ifdef RUBY_VENDOR_THIN_ARCHLIB
    00076     RUBY_VENDOR_THIN_ARCHLIB "\0"
    00077 #endif
    00078     RUBY_VENDOR_ARCHLIB "\0"
    00079     RUBY_VENDOR_LIB "\0"
    00080
    00081     RUBY_LIB "\0"
    00082 #ifdef RUBY_THIN_ARCHLIB
    00083     RUBY_THIN_ARCHLIB "\0"
    00084 #endif
    00085     RUBY_ARCHLIB "\0"
    00086 #endif
    00087     "";
    00088
    00089 void
    00090 Init_version(void)
    00091 {
    00092     rb_define_global_const("RUBY_VERSION", MKSTR(version));
    00093     rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
    00094     rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
    00095     rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
    00096     rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
    00097     rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
    00098     rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
    00099     rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
    00100 }
    00101
    00102 void
    00103 ruby_show_version(void)
    00104 {
    00105     PRINT(description);
    00106     fflush(stdout);
    00107 }
    00108
    00109 void
    00110 ruby_show_copyright(void)
    00111 {
    00112     PRINT(copyright);
    00113     exit(0);
    00114 }
    00115