version.c 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * version.c --- Return the version of the blkid library
  3. *
  4. * Copyright (C) 2004 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 "blkid.h"
  18. #include "../../version.h"
  19. static const char *lib_version = E2FSPROGS_VERSION;
  20. static const char *lib_date = E2FSPROGS_DATE;
  21. int blkid_parse_version_string(const char *ver_string)
  22. {
  23. const char *cp;
  24. int version = 0;
  25. for (cp = ver_string; *cp; cp++) {
  26. if (*cp == '.')
  27. continue;
  28. if (!isdigit(*cp))
  29. break;
  30. version = (version * 10) + (*cp - '0');
  31. }
  32. return version;
  33. }
  34. int blkid_get_library_version(const char **ver_string,
  35. const char **date_string)
  36. {
  37. if (ver_string)
  38. *ver_string = lib_version;
  39. if (date_string)
  40. *date_string = lib_date;
  41. return blkid_parse_version_string(lib_version);
  42. }