Ruby  1.9.3p448(2013-06-27revision41675)
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 #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 int ruby_api_version[] = {
00054     RUBY_API_VERSION_MAJOR,
00055     RUBY_API_VERSION_MINOR,
00056     RUBY_API_VERSION_TEENY,
00057 };
00058 const char ruby_version[] = RUBY_VERSION;
00059 const char ruby_release_date[] = RUBY_RELEASE_DATE;
00060 const char ruby_platform[] = RUBY_PLATFORM;
00061 const int ruby_patchlevel = RUBY_PATCHLEVEL;
00062 const char ruby_description[] = RUBY_DESCRIPTION;
00063 const char ruby_copyright[] = RUBY_COPYRIGHT;
00064 const char ruby_engine[] = "ruby";
00065 VALUE ruby_engine_name = Qnil;
00066 
00067 const char ruby_initial_load_paths[] =
00068 #ifndef NO_INITIAL_LOAD_PATH
00069 #ifdef RUBY_SEARCH_PATH
00070     RUBY_SEARCH_PATH "\0"
00071 #endif
00072 #ifndef NO_RUBY_SITE_LIB
00073     RUBY_SITE_LIB2 "\0"
00074 #ifdef RUBY_SITE_THIN_ARCHLIB
00075     RUBY_SITE_THIN_ARCHLIB "\0"
00076 #endif
00077     RUBY_SITE_ARCHLIB "\0"
00078     RUBY_SITE_LIB "\0"
00079 #endif
00080 
00081 #ifndef NO_RUBY_VENDOR_LIB
00082     RUBY_VENDOR_LIB2 "\0"
00083 #ifdef RUBY_VENDOR_THIN_ARCHLIB
00084     RUBY_VENDOR_THIN_ARCHLIB "\0"
00085 #endif
00086     RUBY_VENDOR_ARCHLIB "\0"
00087     RUBY_VENDOR_LIB "\0"
00088 #endif
00089 
00090     RUBY_LIB "\0"
00091 #ifdef RUBY_THIN_ARCHLIB
00092     RUBY_THIN_ARCHLIB "\0"
00093 #endif
00094     RUBY_ARCHLIB "\0"
00095 #endif
00096     "";
00097 
00098 void
00099 Init_version(void)
00100 {
00101     /*
00102      * The running version of ruby
00103      */
00104     rb_define_global_const("RUBY_VERSION", MKSTR(version));
00105     /*
00106      * The date this ruby was released
00107      */
00108     rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
00109     /*
00110      * The platform for this ruby
00111      */
00112     rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
00113     /*
00114      * The patchlevel for this ruby.  If this is a development build of ruby
00115      * the patchlevel will be -1
00116      */
00117     rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
00118     /*
00119      * The SVN revision for this ruby.
00120      */
00121     rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
00122     /*
00123      * The full ruby version string, like <tt>ruby -v</tt> prints'
00124      */
00125     rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
00126     /*
00127      * The copyright string for ruby
00128      */
00129     rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
00130     /*
00131      * The engine or interpreter this ruby uses.
00132      */
00133     rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
00134 }
00135 
00136 void
00137 ruby_show_version(void)
00138 {
00139     PRINT(description);
00140     fflush(stdout);
00141 }
00142 
00143 void
00144 ruby_show_copyright(void)
00145 {
00146     PRINT(copyright);
00147     exit(0);
00148 }
00149