Ruby  1.9.3p448(2013-06-27revision41675)
version.c
Go to the documentation of this file.
1 /**********************************************************************
2 
3  version.c -
4 
5  $Author: drbrain $
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 #define PRINT(type) puts(ruby_##type)
17 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
18 
19 #ifndef RUBY_ARCH
20 #define RUBY_ARCH RUBY_PLATFORM
21 #endif
22 #ifndef RUBY_SITEARCH
23 #define RUBY_SITEARCH RUBY_ARCH
24 #endif
25 #ifdef RUBY_PLATFORM_CPU
26 #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
27 #endif
28 #ifndef RUBY_LIB_PREFIX
29 #ifndef RUBY_EXEC_PREFIX
30 #error RUBY_EXEC_PREFIX must be defined
31 #endif
32 #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby"
33 #endif
34 #ifndef RUBY_SITE_LIB
35 #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby"
36 #endif
37 #ifndef RUBY_VENDOR_LIB
38 #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
39 #endif
40 
41 #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
42 #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
43 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
44 #define RUBY_ARCHLIB RUBY_LIB "/"RUBY_ARCH
45 #define RUBY_SITE_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_SITEARCH
46 #define RUBY_VENDOR_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
47 #ifdef RUBY_THINARCH
48 #define RUBY_THIN_ARCHLIB RUBY_LIB "/"RUBY_THINARCH
49 #define RUBY_SITE_THIN_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_THINARCH
50 #define RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
51 #endif
52 
53 const int ruby_api_version[] = {
57 };
58 const char ruby_version[] = RUBY_VERSION;
64 const char ruby_engine[] = "ruby";
66 
68 #ifndef NO_INITIAL_LOAD_PATH
69 #ifdef RUBY_SEARCH_PATH
70  RUBY_SEARCH_PATH "\0"
71 #endif
72 #ifndef NO_RUBY_SITE_LIB
73  RUBY_SITE_LIB2 "\0"
74 #ifdef RUBY_SITE_THIN_ARCHLIB
75  RUBY_SITE_THIN_ARCHLIB "\0"
76 #endif
78  RUBY_SITE_LIB "\0"
79 #endif
80 
81 #ifndef NO_RUBY_VENDOR_LIB
82  RUBY_VENDOR_LIB2 "\0"
83 #ifdef RUBY_VENDOR_THIN_ARCHLIB
84  RUBY_VENDOR_THIN_ARCHLIB "\0"
85 #endif
87  RUBY_VENDOR_LIB "\0"
88 #endif
89 
90  RUBY_LIB "\0"
91 #ifdef RUBY_THIN_ARCHLIB
92  RUBY_THIN_ARCHLIB "\0"
93 #endif
94  RUBY_ARCHLIB "\0"
95 #endif
96  "";
97 
98 void
100 {
101  /*
102  * The running version of ruby
103  */
104  rb_define_global_const("RUBY_VERSION", MKSTR(version));
105  /*
106  * The date this ruby was released
107  */
108  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
109  /*
110  * The platform for this ruby
111  */
112  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
113  /*
114  * The patchlevel for this ruby. If this is a development build of ruby
115  * the patchlevel will be -1
116  */
117  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
118  /*
119  * The SVN revision for this ruby.
120  */
121  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
122  /*
123  * The full ruby version string, like <tt>ruby -v</tt> prints'
124  */
125  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
126  /*
127  * The copyright string for ruby
128  */
129  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
130  /*
131  * The engine or interpreter this ruby uses.
132  */
133  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
134 }
135 
136 void
138 {
139  PRINT(description);
140  fflush(stdout);
141 }
142 
143 void
145 {
146  PRINT(copyright);
147  exit(0);
148 }
149