3
0

version.c 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * version.c --- Return the version of the ext2 library
  4. *
  5. * Copyright (C) 1997 Theodore Ts'o.
  6. *
  7. * %Begin-Header%
  8. * This file may be redistributed under the terms of the GNU Public
  9. * License.
  10. * %End-Header%
  11. */
  12. #if HAVE_UNISTD_H
  13. #include <unistd.h>
  14. #endif
  15. #include <string.h>
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #include "ext2_fs.h"
  19. #include "ext2fs.h"
  20. static const char *lib_version = E2FSPROGS_VERSION;
  21. static const char *lib_date = E2FSPROGS_DATE;
  22. int ext2fs_parse_version_string(const char *ver_string)
  23. {
  24. const char *cp;
  25. int version = 0;
  26. for (cp = ver_string; *cp; cp++) {
  27. if (*cp == '.')
  28. continue;
  29. if (!isdigit(*cp))
  30. break;
  31. version = (version * 10) + (*cp - '0');
  32. }
  33. return version;
  34. }
  35. int ext2fs_get_library_version(const char **ver_string,
  36. const char **date_string)
  37. {
  38. if (ver_string)
  39. *ver_string = lib_version;
  40. if (date_string)
  41. *date_string = lib_date;
  42. return ext2fs_parse_version_string(lib_version);
  43. }