Ruby  2.1.3p242(2014-09-19revision47630)
version.c
Go to the documentation of this file.
1 /**********************************************************************
2 
3  version.c -
4 
5  $Author: nobu $
6  created at: Thu Sep 30 20:08:01 JST 1993
7 
8  Copyright (C) 1993-2007 Yukihiro Matsumoto
9 
10 **********************************************************************/
11 
12 #include "ruby/ruby.h"
13 #include "version.h"
14 #include <stdio.h>
15 
16 #ifndef EXIT_SUCCESS
17 #define EXIT_SUCCESS 0
18 #endif
19 
20 #define PRINT(type) puts(ruby_##type)
21 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
22 
23 const int ruby_api_version[] = {
27 };
28 const char ruby_version[] = RUBY_VERSION;
34 const char ruby_engine[] = "ruby";
36 
38 void
40 {
41  /*
42  * The running version of ruby
43  */
44  rb_define_global_const("RUBY_VERSION", MKSTR(version));
45  /*
46  * The date this ruby was released
47  */
48  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
49  /*
50  * The platform for this ruby
51  */
52  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
53  /*
54  * The patchlevel for this ruby. If this is a development build of ruby
55  * the patchlevel will be -1
56  */
57  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
58  /*
59  * The SVN revision for this ruby.
60  */
61  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
62  /*
63  * The full ruby version string, like <tt>ruby -v</tt> prints'
64  */
65  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
66  /*
67  * The copyright string for ruby
68  */
69  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
70  /*
71  * The engine or interpreter this ruby uses.
72  */
73  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
74 }
75 
77 void
79 {
80  PRINT(description);
81  fflush(stdout);
82 }
83 
87 void
89 {
90  PRINT(copyright);
91  exit(EXIT_SUCCESS);
92 }
93