Ruby  1.9.3p484(2013-11-22revision43786)
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 #ifdef DISABLE_VERSIONED_PATHS
42 #define RUBY_LIB RUBY_LIB_PREFIX
43 #define RUBY_SITE_LIB2 RUBY_SITE_LIB
44 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB
45 #else
46 #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
47 #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
48 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
49 #endif
50 #ifndef RUBY_ARCHLIB
51 #define RUBY_ARCHLIB RUBY_LIB "/"RUBY_ARCH
52 #endif
53 #ifndef RUBY_SITE_ARCHLIB
54 #define RUBY_SITE_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_SITEARCH
55 #endif
56 #ifndef RUBY_VENDOR_ARCHLIB
57 #define RUBY_VENDOR_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
58 #endif
59 #ifdef RUBY_THINARCH
60 #define RUBY_THIN_ARCHLIB RUBY_LIB "/"RUBY_THINARCH
61 #define RUBY_SITE_THIN_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_THINARCH
62 #define RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
63 #endif
64 
65 const int ruby_api_version[] = {
69 };
70 const char ruby_version[] = RUBY_VERSION;
76 const char ruby_engine[] = "ruby";
78 
80 #ifndef NO_INITIAL_LOAD_PATH
81 #ifdef RUBY_SEARCH_PATH
82  RUBY_SEARCH_PATH "\0"
83 #endif
84 #ifndef NO_RUBY_SITE_LIB
85  RUBY_SITE_LIB2 "\0"
86 #ifdef RUBY_SITE_THIN_ARCHLIB
87  RUBY_SITE_THIN_ARCHLIB "\0"
88 #endif
90 #ifndef DISABLE_VERSIONED_PATHS
91  RUBY_SITE_LIB "\0"
92 #endif
93 #endif
94 
95 #ifndef NO_RUBY_VENDOR_LIB
96  RUBY_VENDOR_LIB2 "\0"
97 #ifdef RUBY_VENDOR_THIN_ARCHLIB
98  RUBY_VENDOR_THIN_ARCHLIB "\0"
99 #endif
101 #ifndef DISABLE_VERSIONED_PATHS
102  RUBY_VENDOR_LIB "\0"
103 #endif
104 #endif
105 
106 #ifdef RUBYGEMS_DIR
107  RUBYGEMS_DIR "\0"
108 #endif
109 
110  RUBY_LIB "\0"
111 #ifdef RUBY_THIN_ARCHLIB
112  RUBY_THIN_ARCHLIB "\0"
113 #endif
114  RUBY_ARCHLIB "\0"
115 #endif
116  "";
117 
118 void
120 {
121  /*
122  * The running version of ruby
123  */
124  rb_define_global_const("RUBY_VERSION", MKSTR(version));
125  /*
126  * The date this ruby was released
127  */
128  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
129  /*
130  * The platform for this ruby
131  */
132  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
133  /*
134  * The patchlevel for this ruby. If this is a development build of ruby
135  * the patchlevel will be -1
136  */
137  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
138  /*
139  * The SVN revision for this ruby.
140  */
141  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
142  /*
143  * The full ruby version string, like <tt>ruby -v</tt> prints'
144  */
145  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
146  /*
147  * The copyright string for ruby
148  */
149  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
150  /*
151  * The engine or interpreter this ruby uses.
152  */
153  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
154 }
155 
156 void
158 {
159  PRINT(description);
160  fflush(stdout);
161 }
162 
163 void
165 {
166  PRINT(copyright);
167  exit(0);
168 }
169