version.c 4.2 KB

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