summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2000-03-23 11:43:06 +0100
committerLinus Nordberg <linus@nordberg.se>2000-03-23 11:43:06 +0100
commit15e0c19650ba0cf458ce1e0d26a201003679c8e3 (patch)
treefb0a7579ad64df27b7f3a604ea53ce11850df52d
parent41aebe3d15e16c76be5a613bb49184c0fc2f526c (diff)
downloadgmp-15e0c19650ba0cf458ce1e0d26a201003679c8e3.tar.gz
Change copyright header.
(__gmp_version_struct): New struct. (gmp_version): Is now a function.
-rw-r--r--version.c80
1 files changed, 76 insertions, 4 deletions
diff --git a/version.c b/version.c
index dd0593d2c..480069358 100644
--- a/version.c
+++ b/version.c
@@ -1,7 +1,7 @@
/* gmp_version -- version number compiled into the library */
/*
-Copyright (C) 1996,1999,2000 Free Software Foundation, Inc.
+Copyright (C) 1996, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -17,10 +17,82 @@ License for more details.
You should have received a copy of the GNU Library General Public License
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <string.h>
+#endif
#include "gmp.h"
#include "gmp-impl.h"
-static const char *gmp_version = VERSION;
+static struct
+{
+ int major, minor, patchlevel;
+} __gmp_version_struct = {0, 0, 0};
+
+int
+#if __STDC__
+gmp_version (gmp_version_enum v)
+#else
+gmp_version (v)
+ gmp_version_enum v;
+#endif
+{
+ if (__gmp_version_struct.major == 0
+ && __gmp_version_struct.minor == 0
+ && __gmp_version_struct.patchlevel == 0)
+ {
+ /* Initialize struct. */
+ char *ver_str;
+ char c;
+ char *cp, *start;
+ TMP_DECL (mark);
+
+ TMP_MARK (mark);
+ ver_str = TMP_ALLOC (strlen (VERSION) + 1);
+ strcpy (ver_str, VERSION);
+
+ start = cp = ver_str;
+ while (*cp != '.' && *cp != '\0')
+ cp++;
+ c = *cp; *cp = '\0';
+ __gmp_version_struct.major = atoi (start);
+
+ if (c == '.')
+ {
+ start = ++cp;
+ while (*cp != '.' && *cp != '\0')
+ cp++;
+ c = *cp; *cp = '\0';
+ __gmp_version_struct.minor = atoi (start);
+
+ if (c == '.')
+ {
+ start = ++cp;
+ while (*cp != '.' && *cp != '\0')
+ cp++;
+ *cp = '\0';
+ __gmp_version_struct.patchlevel = atoi (start);
+ }
+ }
+ TMP_FREE (mark);
+ }
+
+ switch (v)
+ {
+ case GMP_GET_VERSION_MAJOR:
+ return __gmp_version_struct.major;
+ case GMP_GET_VERSION_MINOR:
+ return __gmp_version_struct.minor;
+ case GMP_GET_VERSION_PATCHLEVEL:
+ return __gmp_version_struct.patchlevel;
+ default:
+ gmp_errno |= GMP_ERROR_INVALID_ARGUMENT;
+ return 0;
+ }
+}
+
+