exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / check-version.c
bloba092cb5d54b71d649abb31f3657c657397a3a6a3
1 /* check-version.h --- Check version string compatibility.
2 Copyright (C) 1998-2006, 2008-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Simon Josefsson. This interface is influenced by
18 gcry_check_version from Werner Koch's Libgcrypt. Paul Eggert
19 suggested the use of strverscmp to simplify implementation. */
21 #include <config.h>
23 #include <stddef.h>
24 #include <string.h>
26 /* Get specification. */
27 #include "check-version.h"
29 /* Check that the version of the library (i.e., the CPP symbol VERSION)
30 * is at minimum the requested one in REQ_VERSION (typically found in
31 * a header file) and return the version string. Return NULL if the
32 * condition is not satisfied. If a NULL is passed to this function,
33 * no check is done, but the version string is simply returned.
35 const char *
36 check_version (const char *req_version)
38 if (!req_version || strverscmp (req_version, VERSION) <= 0)
39 return VERSION;
41 return NULL;