version.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* version.c --- Version handling.
  2. Copyright (C) 2002-2024 Simon Josefsson
  3. This file is part of GNU Libidn.
  4. GNU Libidn is free software: you can redistribute it and/or
  5. modify it under the terms of either:
  6. * the GNU Lesser General Public License as published by the Free
  7. Software Foundation; either version 3 of the License, or (at
  8. your option) any later version.
  9. or
  10. * the GNU General Public License as published by the Free
  11. Software Foundation; either version 2 of the License, or (at
  12. your option) any later version.
  13. or both in parallel, as here.
  14. GNU Libidn is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. General Public License for more details.
  18. You should have received copies of the GNU General Public License and
  19. the GNU Lesser General Public License along with this program. If
  20. not, see <https://www.gnu.org/licenses/>. */
  21. #ifdef HAVE_CONFIG_H
  22. # include "config.h"
  23. #endif
  24. #include "stringprep.h"
  25. #include <string.h> /* for strverscmp */
  26. /**
  27. * stringprep_check_version:
  28. * @req_version: Required version number, or NULL.
  29. *
  30. * Check that the version of the library is at minimum the requested one
  31. * and return the version string; return NULL if the condition is not
  32. * satisfied. If a NULL is passed to this function, no check is done,
  33. * but the version string is simply returned.
  34. *
  35. * See %STRINGPREP_VERSION for a suitable @req_version string.
  36. *
  37. * Return value: Version string of run-time library, or NULL if the
  38. * run-time library does not meet the required version number.
  39. */
  40. const char *
  41. stringprep_check_version (const char *req_version)
  42. {
  43. if (!req_version || strverscmp (req_version, STRINGPREP_VERSION) <= 0)
  44. return STRINGPREP_VERSION;
  45. return NULL;
  46. }