Commit | Line | Data |
---|---|---|
58ade102 | 1 | /* Copyright (C) 1995,1996, 1999, 2000, 2001 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 | |
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | */ | |
1bbd0b84 | 17 | |
1bbd0b84 | 18 | |
9d7e1edf JB |
19 | \f |
20 | ||
3143f109 | 21 | #include <stdio.h> |
a0599745 MD |
22 | #include "libguile/_scm.h" |
23 | #include "libguile/strings.h" | |
9d7e1edf | 24 | |
a0599745 | 25 | #include "libguile/version.h" |
9d7e1edf JB |
26 | \f |
27 | ||
3143f109 RB |
28 | #define SCM_TMP_MACRO_MKSTR(x) #x |
29 | ||
9d7e1edf JB |
30 | /* Return a Scheme string containing Guile's major version number. */ |
31 | ||
3b3b36dd | 32 | SCM_DEFINE (scm_major_version, "major-version", 0, 0, 0, |
d727c64b GB |
33 | (), |
34 | "Return a string containing Guile's major version number.\n" | |
b89d554b | 35 | "E.g., the 1 in \"1.6.5\".") |
1bbd0b84 | 36 | #define FUNC_NAME s_scm_major_version |
9d7e1edf | 37 | { |
e11e83f3 MV |
38 | return scm_number_to_string (scm_from_int (SCM_MAJOR_VERSION), |
39 | scm_from_int (10)); | |
9d7e1edf | 40 | } |
1bbd0b84 | 41 | #undef FUNC_NAME |
9d7e1edf JB |
42 | |
43 | /* Return a Scheme string containing Guile's minor version number. */ | |
44 | ||
3b3b36dd | 45 | SCM_DEFINE (scm_minor_version, "minor-version", 0, 0, 0, |
d727c64b GB |
46 | (), |
47 | "Return a string containing Guile's minor version number.\n" | |
b89d554b | 48 | "E.g., the 6 in \"1.6.5\".") |
1bbd0b84 | 49 | #define FUNC_NAME s_scm_minor_version |
9d7e1edf | 50 | { |
e11e83f3 MV |
51 | return scm_number_to_string (scm_from_int (SCM_MINOR_VERSION), |
52 | scm_from_int (10)); | |
9d7e1edf | 53 | } |
1bbd0b84 | 54 | #undef FUNC_NAME |
9d7e1edf | 55 | |
41bc3f42 | 56 | /* Return a Scheme string containing Guile's micro version number. */ |
b89d554b RB |
57 | |
58 | SCM_DEFINE (scm_micro_version, "micro-version", 0, 0, 0, | |
59 | (), | |
60 | "Return a string containing Guile's micro version number.\n" | |
61 | "E.g., the 5 in \"1.6.5\".") | |
41bc3f42 | 62 | #define FUNC_NAME s_scm_micro_version |
b89d554b | 63 | { |
e11e83f3 MV |
64 | return scm_number_to_string (scm_from_int (SCM_MICRO_VERSION), |
65 | scm_from_int (10)); | |
b89d554b RB |
66 | } |
67 | #undef FUNC_NAME | |
68 | ||
9d7e1edf JB |
69 | /* Return a Scheme string containing Guile's complete version. */ |
70 | ||
3b3b36dd | 71 | SCM_DEFINE (scm_version, "version", 0, 0, 0, |
d727c64b | 72 | (), |
8f85c0c6 NJ |
73 | "@deffnx {Scheme Procedure} major-version\n" |
74 | "@deffnx {Scheme Procedure} minor-version\n" | |
75 | "@deffnx {Scheme Procedure} micro-version\n" | |
72dd0a03 NJ |
76 | "Return a string describing Guile's version number, or its major, minor\n" |
77 | "or micro version number, respectively.\n\n" | |
1e6808ea | 78 | "@lisp\n" |
72dd0a03 | 79 | "(version) @result{} \"1.6.0\"\n" |
d3818c29 | 80 | "(major-version) @result{} \"1\"\n" |
72dd0a03 NJ |
81 | "(minor-version) @result{} \"6\"\n" |
82 | "(micro-version) @result{} \"0\"\n" | |
1e6808ea | 83 | "@end lisp") |
1bbd0b84 | 84 | #define FUNC_NAME s_scm_version |
9d7e1edf | 85 | { |
3143f109 | 86 | |
8186c4f5 | 87 | char version_str[3 * 4 + 3]; |
3143f109 | 88 | |
76f33258 RB |
89 | #if SCM_MAJOR_VERSION > 9999 \ |
90 | || SCM_MINOR_VERSION > 9999 \ | |
91 | || SCM_MICRO_VERSION > 9999 | |
8186c4f5 GH |
92 | # error version string may overflow buffer |
93 | #endif | |
94 | sprintf (version_str, "%d.%d.%d", | |
2ff4f181 MD |
95 | SCM_MAJOR_VERSION, |
96 | SCM_MINOR_VERSION, | |
97 | SCM_MICRO_VERSION); | |
cc95e00a | 98 | return scm_from_locale_string (version_str); |
9d7e1edf | 99 | } |
1bbd0b84 | 100 | #undef FUNC_NAME |
9d7e1edf | 101 | |
ccf01e3e RB |
102 | /* Return a Scheme string containing Guile's effective version. */ |
103 | ||
104 | SCM_DEFINE (scm_effective_version, "effective-version", 0, 0, 0, | |
105 | (), | |
106 | "Return a string describing Guile's effective version number.\n" | |
107 | "@lisp\n" | |
108 | "(version) @result{} \"1.6.0\"\n" | |
109 | "(effective-version) @result{} \"1.6\"\n" | |
110 | "(major-version) @result{} \"1\"\n" | |
111 | "(minor-version) @result{} \"6\"\n" | |
112 | "(micro-version) @result{} \"0\"\n" | |
113 | "@end lisp") | |
114 | #define FUNC_NAME s_scm_effective_version | |
115 | { | |
116 | ||
117 | char version_str[2 * 4 + 3]; | |
118 | ||
119 | #if (SCM_MAJOR_VERSION > 9999 || SCM_MINOR_VERSION > 9999) | |
120 | # error version string may overflow buffer | |
121 | #endif | |
2ff4f181 | 122 | sprintf (version_str, "%d.%d", SCM_MAJOR_VERSION, SCM_MINOR_VERSION); |
cc95e00a | 123 | return scm_from_locale_string (version_str); |
ccf01e3e RB |
124 | } |
125 | #undef FUNC_NAME | |
126 | ||
9d7e1edf JB |
127 | \f |
128 | ||
1cc91f1b | 129 | |
9d7e1edf JB |
130 | void |
131 | scm_init_version () | |
9d7e1edf | 132 | { |
a0599745 | 133 | #include "libguile/version.x" |
9d7e1edf | 134 | } |
89e00824 ML |
135 | |
136 | /* | |
137 | Local Variables: | |
138 | c-file-style: "gnu" | |
139 | End: | |
140 | */ |