| 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 |
| 5 | * License as published by the Free Software Foundation; either |
| 6 | * version 2.1 of the License, or (at your option) any later version. |
| 7 | * |
| 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. |
| 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 02110-1301 USA |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | \f |
| 20 | #ifdef HAVE_CONFIG_H |
| 21 | # include <config.h> |
| 22 | #endif |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include "libguile/_scm.h" |
| 26 | #include "libguile/strings.h" |
| 27 | |
| 28 | #include "libguile/version.h" |
| 29 | \f |
| 30 | |
| 31 | #define SCM_TMP_MACRO_MKSTR(x) #x |
| 32 | |
| 33 | /* Return a Scheme string containing Guile's major version number. */ |
| 34 | |
| 35 | SCM_DEFINE (scm_major_version, "major-version", 0, 0, 0, |
| 36 | (), |
| 37 | "Return a string containing Guile's major version number.\n" |
| 38 | "E.g., the 1 in \"1.6.5\".") |
| 39 | #define FUNC_NAME s_scm_major_version |
| 40 | { |
| 41 | return scm_number_to_string (scm_from_int (SCM_MAJOR_VERSION), |
| 42 | scm_from_int (10)); |
| 43 | } |
| 44 | #undef FUNC_NAME |
| 45 | |
| 46 | /* Return a Scheme string containing Guile's minor version number. */ |
| 47 | |
| 48 | SCM_DEFINE (scm_minor_version, "minor-version", 0, 0, 0, |
| 49 | (), |
| 50 | "Return a string containing Guile's minor version number.\n" |
| 51 | "E.g., the 6 in \"1.6.5\".") |
| 52 | #define FUNC_NAME s_scm_minor_version |
| 53 | { |
| 54 | return scm_number_to_string (scm_from_int (SCM_MINOR_VERSION), |
| 55 | scm_from_int (10)); |
| 56 | } |
| 57 | #undef FUNC_NAME |
| 58 | |
| 59 | /* Return a Scheme string containing Guile's micro version number. */ |
| 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\".") |
| 65 | #define FUNC_NAME s_scm_micro_version |
| 66 | { |
| 67 | return scm_number_to_string (scm_from_int (SCM_MICRO_VERSION), |
| 68 | scm_from_int (10)); |
| 69 | } |
| 70 | #undef FUNC_NAME |
| 71 | |
| 72 | /* Return a Scheme string containing Guile's complete version. */ |
| 73 | |
| 74 | SCM_DEFINE (scm_version, "version", 0, 0, 0, |
| 75 | (), |
| 76 | "@deffnx {Scheme Procedure} major-version\n" |
| 77 | "@deffnx {Scheme Procedure} minor-version\n" |
| 78 | "@deffnx {Scheme Procedure} micro-version\n" |
| 79 | "Return a string describing Guile's version number, or its major, minor\n" |
| 80 | "or micro version number, respectively.\n\n" |
| 81 | "@lisp\n" |
| 82 | "(version) @result{} \"1.6.0\"\n" |
| 83 | "(major-version) @result{} \"1\"\n" |
| 84 | "(minor-version) @result{} \"6\"\n" |
| 85 | "(micro-version) @result{} \"0\"\n" |
| 86 | "@end lisp") |
| 87 | #define FUNC_NAME s_scm_version |
| 88 | { |
| 89 | return scm_from_locale_string (PACKAGE_VERSION); |
| 90 | } |
| 91 | #undef FUNC_NAME |
| 92 | |
| 93 | /* Return a Scheme string containing Guile's effective version. */ |
| 94 | |
| 95 | SCM_DEFINE (scm_effective_version, "effective-version", 0, 0, 0, |
| 96 | (), |
| 97 | "Return a string describing Guile's effective version number.\n" |
| 98 | "@lisp\n" |
| 99 | "(version) @result{} \"1.6.0\"\n" |
| 100 | "(effective-version) @result{} \"1.6\"\n" |
| 101 | "(major-version) @result{} \"1\"\n" |
| 102 | "(minor-version) @result{} \"6\"\n" |
| 103 | "(micro-version) @result{} \"0\"\n" |
| 104 | "@end lisp") |
| 105 | #define FUNC_NAME s_scm_effective_version |
| 106 | { |
| 107 | |
| 108 | char version_str[2 * 4 + 3]; |
| 109 | |
| 110 | #if (SCM_MAJOR_VERSION > 9999 || SCM_MINOR_VERSION > 9999) |
| 111 | # error version string may overflow buffer |
| 112 | #endif |
| 113 | sprintf (version_str, "%d.%d", SCM_MAJOR_VERSION, SCM_MINOR_VERSION); |
| 114 | return scm_from_locale_string (version_str); |
| 115 | } |
| 116 | #undef FUNC_NAME |
| 117 | |
| 118 | \f |
| 119 | |
| 120 | |
| 121 | void |
| 122 | scm_init_version () |
| 123 | { |
| 124 | #include "libguile/version.x" |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | Local Variables: |
| 129 | c-file-style: "gnu" |
| 130 | End: |
| 131 | */ |