Ruby 1.9.3p327(2012-11-10revision37606)
version.c
Go to the documentation of this file.
00001 /**********************************************************************
00002 
00003   version.c -
00004 
00005   $Author: drbrain $
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 #ifdef DISABLE_VERSIONED_PATHS
00042 #define RUBY_LIB                    RUBY_LIB_PREFIX
00043 #define RUBY_SITE_LIB2              RUBY_SITE_LIB
00044 #define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB
00045 #else
00046 #define RUBY_LIB                    RUBY_LIB_PREFIX  "/"RUBY_LIB_VERSION
00047 #define RUBY_SITE_LIB2              RUBY_SITE_LIB    "/"RUBY_LIB_VERSION
00048 #define RUBY_VENDOR_LIB2            RUBY_VENDOR_LIB  "/"RUBY_LIB_VERSION
00049 #endif
00050 #ifndef RUBY_ARCHLIB
00051 #define RUBY_ARCHLIB                RUBY_LIB         "/"RUBY_ARCH
00052 #endif
00053 #ifndef RUBY_SITE_ARCHLIB
00054 #define RUBY_SITE_ARCHLIB           RUBY_SITE_LIB2   "/"RUBY_SITEARCH
00055 #endif
00056 #ifndef RUBY_VENDOR_ARCHLIB
00057 #define RUBY_VENDOR_ARCHLIB         RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
00058 #endif
00059 #ifdef  RUBY_THINARCH
00060 #define RUBY_THIN_ARCHLIB           RUBY_LIB         "/"RUBY_THINARCH
00061 #define RUBY_SITE_THIN_ARCHLIB      RUBY_SITE_LIB2   "/"RUBY_THINARCH
00062 #define RUBY_VENDOR_THIN_ARCHLIB    RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
00063 #endif
00064 
00065 const int ruby_api_version[] = {
00066     RUBY_API_VERSION_MAJOR,
00067     RUBY_API_VERSION_MINOR,
00068     RUBY_API_VERSION_TEENY,
00069 };
00070 const char ruby_version[] = RUBY_VERSION;
00071 const char ruby_release_date[] = RUBY_RELEASE_DATE;
00072 const char ruby_platform[] = RUBY_PLATFORM;
00073 const int ruby_patchlevel = RUBY_PATCHLEVEL;
00074 const char ruby_description[] = RUBY_DESCRIPTION;
00075 const char ruby_copyright[] = RUBY_COPYRIGHT;
00076 const char ruby_engine[] = "ruby";
00077 VALUE ruby_engine_name = Qnil;
00078 
00079 const char ruby_initial_load_paths[] =
00080 #ifndef NO_INITIAL_LOAD_PATH
00081 #ifdef RUBY_SEARCH_PATH
00082     RUBY_SEARCH_PATH "\0"
00083 #endif
00084 #ifndef NO_RUBY_SITE_LIB
00085     RUBY_SITE_LIB2 "\0"
00086 #ifdef RUBY_SITE_THIN_ARCHLIB
00087     RUBY_SITE_THIN_ARCHLIB "\0"
00088 #endif
00089     RUBY_SITE_ARCHLIB "\0"
00090 #ifndef DISABLE_VERSIONED_PATHS
00091     RUBY_SITE_LIB "\0"
00092 #endif
00093 #endif
00094 
00095 #ifndef NO_RUBY_VENDOR_LIB
00096     RUBY_VENDOR_LIB2 "\0"
00097 #ifdef RUBY_VENDOR_THIN_ARCHLIB
00098     RUBY_VENDOR_THIN_ARCHLIB "\0"
00099 #endif
00100     RUBY_VENDOR_ARCHLIB "\0"
00101 #ifndef DISABLE_VERSIONED_PATHS
00102     RUBY_VENDOR_LIB "\0"
00103 #endif
00104 #endif
00105 
00106 #ifdef RUBYGEMS_DIR
00107     RUBYGEMS_DIR "\0"
00108 #endif
00109 
00110     RUBY_LIB "\0"
00111 #ifdef RUBY_THIN_ARCHLIB
00112     RUBY_THIN_ARCHLIB "\0"
00113 #endif
00114     RUBY_ARCHLIB "\0"
00115 #endif
00116     "";
00117 
00118 void
00119 Init_version(void)
00120 {
00121     /*
00122      * The running version of ruby
00123      */
00124     rb_define_global_const("RUBY_VERSION", MKSTR(version));
00125     /*
00126      * The date this ruby was released
00127      */
00128     rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
00129     /*
00130      * The platform for this ruby
00131      */
00132     rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
00133     /*
00134      * The patchlevel for this ruby.  If this is a development build of ruby
00135      * the patchlevel will be -1
00136      */
00137     rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
00138     /*
00139      * The SVN revision for this ruby.
00140      */
00141     rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
00142     /*
00143      * The full ruby version string, like <tt>ruby -v</tt> prints'
00144      */
00145     rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
00146     /*
00147      * The copyright string for ruby
00148      */
00149     rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
00150     /*
00151      * The engine or interpreter this ruby uses.
00152      */
00153     rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
00154 }
00155 
00156 void
00157 ruby_show_version(void)
00158 {
00159     PRINT(description);
00160     fflush(stdout);
00161 }
00162 
00163 void
00164 ruby_show_copyright(void)
00165 {
00166     PRINT(copyright);
00167     exit(0);
00168 }
00169