Commit | Line | Data |
---|---|---|
dbb605f5 | 1 | /* Copyright (C) 1995,1996, 1999, 2000, 2001, 2006, 2008 Free Software Foundation, Inc. |
9d7e1edf | 2 | * |
73be1d9e MV |
3 | * This library is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU Lesser General Public | |
5 | * License as published by the Free Software Foundation; either | |
6 | * version 2.1 of the License, or (at your option) any later version. | |
9d7e1edf | 7 | * |
73be1d9e MV |
8 | * This library is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * Lesser General Public License for more details. | |
9d7e1edf | 12 | * |
73be1d9e MV |
13 | * You should have received a copy of the GNU Lesser General Public |
14 | * License along with this library; if not, write to the Free Software | |
92205699 | 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 16 | */ |
1bbd0b84 | 17 | |
1bbd0b84 | 18 | |
9d7e1edf | 19 | \f |
dbb605f5 LC |
20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | |
22 | #endif | |
9d7e1edf | 23 | |
3143f109 | 24 | #include <stdio.h> |
a0599745 MD |
25 | #include "libguile/_scm.h" |
26 | #include "libguile/strings.h" | |
9d7e1edf | 27 | |
a0599745 | 28 | #include "libguile/version.h" |
9d7e1edf JB |
29 | \f |
30 | ||
3143f109 RB |
31 | #define SCM_TMP_MACRO_MKSTR(x) #x |
32 | ||
9d7e1edf JB |
33 | /* Return a Scheme string containing Guile's major version number. */ |
34 | ||
3b3b36dd | 35 | SCM_DEFINE (scm_major_version, "major-version", 0, 0, 0, |
d727c64b GB |
36 | (), |
37 | "Return a string containing Guile's major version number.\n" | |
b89d554b | 38 | "E.g., the 1 in \"1.6.5\".") |
1bbd0b84 | 39 | #define FUNC_NAME s_scm_major_version |
9d7e1edf | 40 | { |
e11e83f3 MV |
41 | return scm_number_to_string (scm_from_int (SCM_MAJOR_VERSION), |
42 | scm_from_int (10)); | |
9d7e1edf | 43 | } |
1bbd0b84 | 44 | #undef FUNC_NAME |
9d7e1edf JB |
45 | |
46 | /* Return a Scheme string containing Guile's minor version number. */ | |
47 | ||
3b3b36dd | 48 | SCM_DEFINE (scm_minor_version, "minor-version", 0, 0, 0, |
d727c64b GB |
49 | (), |
50 | "Return a string containing Guile's minor version number.\n" | |
b89d554b | 51 | "E.g., the 6 in \"1.6.5\".") |
1bbd0b84 | 52 | #define FUNC_NAME s_scm_minor_version |
9d7e1edf | 53 | { |
e11e83f3 MV |
54 | return scm_number_to_string (scm_from_int (SCM_MINOR_VERSION), |
55 | scm_from_int (10)); | |
9d7e1edf | 56 | } |
1bbd0b84 | 57 | #undef FUNC_NAME |
9d7e1edf | 58 | |
41bc3f42 | 59 | /* Return a Scheme string containing Guile's micro version number. */ |
b89d554b RB |
60 | |
61 | SCM_DEFINE (scm_micro_version, "micro-version", 0, 0, 0, | |
62 | (), | |
63 | "Return a string containing Guile's micro version number.\n" | |
64 | "E.g., the 5 in \"1.6.5\".") | |
41bc3f42 | 65 | #define FUNC_NAME s_scm_micro_version |
b89d554b | 66 | { |
e11e83f3 MV |
67 | return scm_number_to_string (scm_from_int (SCM_MICRO_VERSION), |
68 | scm_from_int (10)); | |
b89d554b RB |
69 | } |
70 | #undef FUNC_NAME | |
71 | ||
9d7e1edf JB |
72 | /* Return a Scheme string containing Guile's complete version. */ |
73 | ||
3b3b36dd | 74 | SCM_DEFINE (scm_version, "version", 0, 0, 0, |
d727c64b | 75 | (), |
8f85c0c6 NJ |
76 | "@deffnx {Scheme Procedure} major-version\n" |
77 | "@deffnx {Scheme Procedure} minor-version\n" | |
78 | "@deffnx {Scheme Procedure} micro-version\n" | |
72dd0a03 NJ |
79 | "Return a string describing Guile's version number, or its major, minor\n" |
80 | "or micro version number, respectively.\n\n" | |
1e6808ea | 81 | "@lisp\n" |
72dd0a03 | 82 | "(version) @result{} \"1.6.0\"\n" |
d3818c29 | 83 | "(major-version) @result{} \"1\"\n" |
72dd0a03 NJ |
84 | "(minor-version) @result{} \"6\"\n" |
85 | "(micro-version) @result{} \"0\"\n" | |
1e6808ea | 86 | "@end lisp") |
1bbd0b84 | 87 | #define FUNC_NAME s_scm_version |
9d7e1edf | 88 | { |
3143f109 | 89 | |
8186c4f5 | 90 | char version_str[3 * 4 + 3]; |
3143f109 | 91 | |
76f33258 RB |
92 | #if SCM_MAJOR_VERSION > 9999 \ |
93 | || SCM_MINOR_VERSION > 9999 \ | |
94 | || SCM_MICRO_VERSION > 9999 | |
8186c4f5 GH |
95 | # error version string may overflow buffer |
96 | #endif | |
97 | sprintf (version_str, "%d.%d.%d", | |
2ff4f181 MD |
98 | SCM_MAJOR_VERSION, |
99 | SCM_MINOR_VERSION, | |
100 | SCM_MICRO_VERSION); | |
cc95e00a | 101 | return scm_from_locale_string (version_str); |
9d7e1edf | 102 | } |
1bbd0b84 | 103 | #undef FUNC_NAME |
9d7e1edf | 104 | |
ccf01e3e RB |
105 | /* Return a Scheme string containing Guile's effective version. */ |
106 | ||
107 | SCM_DEFINE (scm_effective_version, "effective-version", 0, 0, 0, | |
108 | (), | |
109 | "Return a string describing Guile's effective version number.\n" | |
110 | "@lisp\n" | |
111 | "(version) @result{} \"1.6.0\"\n" | |
112 | "(effective-version) @result{} \"1.6\"\n" | |
113 | "(major-version) @result{} \"1\"\n" | |
114 | "(minor-version) @result{} \"6\"\n" | |
115 | "(micro-version) @result{} \"0\"\n" | |
116 | "@end lisp") | |
117 | #define FUNC_NAME s_scm_effective_version | |
118 | { | |
119 | ||
120 | char version_str[2 * 4 + 3]; | |
121 | ||
122 | #if (SCM_MAJOR_VERSION > 9999 || SCM_MINOR_VERSION > 9999) | |
123 | # error version string may overflow buffer | |
124 | #endif | |
2ff4f181 | 125 | sprintf (version_str, "%d.%d", SCM_MAJOR_VERSION, SCM_MINOR_VERSION); |
cc95e00a | 126 | return scm_from_locale_string (version_str); |
ccf01e3e RB |
127 | } |
128 | #undef FUNC_NAME | |
129 | ||
9d7e1edf JB |
130 | \f |
131 | ||
1cc91f1b | 132 | |
9d7e1edf JB |
133 | void |
134 | scm_init_version () | |
9d7e1edf | 135 | { |
a0599745 | 136 | #include "libguile/version.x" |
9d7e1edf | 137 | } |
89e00824 ML |
138 | |
139 | /* | |
140 | Local Variables: | |
141 | c-file-style: "gnu" | |
142 | End: | |
143 | */ |