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 #ifndef EXIT_SUCCESS
00017 #define EXIT_SUCCESS 0
00018 #endif
00019 
00020 #define PRINT(type) puts(ruby_##type)
00021 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
00022 
00023 const int ruby_api_version[] = {
00024     RUBY_API_VERSION_MAJOR,
00025     RUBY_API_VERSION_MINOR,
00026     RUBY_API_VERSION_TEENY,
00027 };
00028 const char ruby_version[] = RUBY_VERSION;
00029 const char ruby_release_date[] = RUBY_RELEASE_DATE;
00030 const char ruby_platform[] = RUBY_PLATFORM;
00031 const int ruby_patchlevel = RUBY_PATCHLEVEL;
00032 const char ruby_description[] = RUBY_DESCRIPTION;
00033 const char ruby_copyright[] = RUBY_COPYRIGHT;
00034 const char ruby_engine[] = "ruby";
00035 VALUE ruby_engine_name = Qnil;
00036 
00038 void
00039 Init_version(void)
00040 {
00041     /*
00042      * The running version of ruby
00043      */
00044     rb_define_global_const("RUBY_VERSION", MKSTR(version));
00045     /*
00046      * The date this ruby was released
00047      */
00048     rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
00049     /*
00050      * The platform for this ruby
00051      */
00052     rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
00053     /*
00054      * The patchlevel for this ruby.  If this is a development build of ruby
00055      * the patchlevel will be -1
00056      */
00057     rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
00058     /*
00059      * The SVN revision for this ruby.
00060      */
00061     rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
00062     /*
00063      * The full ruby version string, like <tt>ruby -v</tt> prints'
00064      */
00065     rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
00066     /*
00067      * The copyright string for ruby
00068      */
00069     rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
00070     /*
00071      * The engine or interpreter this ruby uses.
00072      */
00073     rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
00074 }
00075 
00077 void
00078 ruby_show_version(void)
00079 {
00080     PRINT(description);
00081     fflush(stdout);
00082 }
00083 
00087 void
00088 ruby_show_copyright(void)
00089 {
00090     PRINT(copyright);
00091     exit(EXIT_SUCCESS);
00092 }
00093 

Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7