3
0

version.c 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * version.c --- Return the version of the ext2 library
  3. *
  4. * Copyright (C) 1997 Theodore Ts'o.
  5. *
  6. * %Begin-Header%
  7. * This file may be redistributed under the terms of the GNU Public
  8. * License.
  9. * %End-Header%
  10. */
  11. #if HAVE_UNISTD_H
  12. #include <unistd.h>
  13. #endif
  14. #include <string.h>
  15. #include <stdio.h>
  16. #include <ctype.h>
  17. #include "ext2_fs.h"
  18. #include "ext2fs.h"
  19. //#include "../../version.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. }