Change Guile license to LGPLv3+
[bpt/guile.git] / libguile / version.c
1 /* Copyright (C) 1995,1996, 1999, 2000, 2001, 2006, 2008 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful, but
9 * 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.
12 *
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., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18
19
20 \f
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24
25 #include <stdio.h>
26 #include "libguile/_scm.h"
27 #include "libguile/strings.h"
28
29 #include "libguile/version.h"
30 \f
31
32 #define SCM_TMP_MACRO_MKSTR(x) #x
33
34 /* Return a Scheme string containing Guile's major version number. */
35
36 SCM_DEFINE (scm_major_version, "major-version", 0, 0, 0,
37 (),
38 "Return a string containing Guile's major version number.\n"
39 "E.g., the 1 in \"1.6.5\".")
40 #define FUNC_NAME s_scm_major_version
41 {
42 return scm_number_to_string (scm_from_int (SCM_MAJOR_VERSION),
43 scm_from_int (10));
44 }
45 #undef FUNC_NAME
46
47 /* Return a Scheme string containing Guile's minor version number. */
48
49 SCM_DEFINE (scm_minor_version, "minor-version", 0, 0, 0,
50 (),
51 "Return a string containing Guile's minor version number.\n"
52 "E.g., the 6 in \"1.6.5\".")
53 #define FUNC_NAME s_scm_minor_version
54 {
55 return scm_number_to_string (scm_from_int (SCM_MINOR_VERSION),
56 scm_from_int (10));
57 }
58 #undef FUNC_NAME
59
60 /* Return a Scheme string containing Guile's micro version number. */
61
62 SCM_DEFINE (scm_micro_version, "micro-version", 0, 0, 0,
63 (),
64 "Return a string containing Guile's micro version number.\n"
65 "E.g., the 5 in \"1.6.5\".")
66 #define FUNC_NAME s_scm_micro_version
67 {
68 return scm_number_to_string (scm_from_int (SCM_MICRO_VERSION),
69 scm_from_int (10));
70 }
71 #undef FUNC_NAME
72
73 /* Return a Scheme string containing Guile's complete version. */
74
75 SCM_DEFINE (scm_version, "version", 0, 0, 0,
76 (),
77 "@deffnx {Scheme Procedure} major-version\n"
78 "@deffnx {Scheme Procedure} minor-version\n"
79 "@deffnx {Scheme Procedure} micro-version\n"
80 "Return a string describing Guile's version number, or its major, minor\n"
81 "or micro version number, respectively.\n\n"
82 "@lisp\n"
83 "(version) @result{} \"1.6.0\"\n"
84 "(major-version) @result{} \"1\"\n"
85 "(minor-version) @result{} \"6\"\n"
86 "(micro-version) @result{} \"0\"\n"
87 "@end lisp")
88 #define FUNC_NAME s_scm_version
89 {
90
91 char version_str[3 * 4 + 3];
92
93 #if SCM_MAJOR_VERSION > 9999 \
94 || SCM_MINOR_VERSION > 9999 \
95 || SCM_MICRO_VERSION > 9999
96 # error version string may overflow buffer
97 #endif
98 sprintf (version_str, "%d.%d.%d",
99 SCM_MAJOR_VERSION,
100 SCM_MINOR_VERSION,
101 SCM_MICRO_VERSION);
102 return scm_from_locale_string (version_str);
103 }
104 #undef FUNC_NAME
105
106 /* Return a Scheme string containing Guile's effective version. */
107
108 SCM_DEFINE (scm_effective_version, "effective-version", 0, 0, 0,
109 (),
110 "Return a string describing Guile's effective version number.\n"
111 "@lisp\n"
112 "(version) @result{} \"1.6.0\"\n"
113 "(effective-version) @result{} \"1.6\"\n"
114 "(major-version) @result{} \"1\"\n"
115 "(minor-version) @result{} \"6\"\n"
116 "(micro-version) @result{} \"0\"\n"
117 "@end lisp")
118 #define FUNC_NAME s_scm_effective_version
119 {
120
121 char version_str[2 * 4 + 3];
122
123 #if (SCM_MAJOR_VERSION > 9999 || SCM_MINOR_VERSION > 9999)
124 # error version string may overflow buffer
125 #endif
126 sprintf (version_str, "%d.%d", SCM_MAJOR_VERSION, SCM_MINOR_VERSION);
127 return scm_from_locale_string (version_str);
128 }
129 #undef FUNC_NAME
130
131 \f
132
133
134 void
135 scm_init_version ()
136 {
137 #include "libguile/version.x"
138 }
139
140 /*
141 Local Variables:
142 c-file-style: "gnu"
143 End:
144 */