havelib: Fix for Solaris 11 OpenIndiana and Solaris 11 OmniOS.
[gnulib.git] / lib / check-version.c
blob3fe097e8d44b479c3b1f1d2a18a70c38d79a6fd5
1 /* check-version.h --- Check version string compatibility.
2 Copyright (C) 1998-2006, 2008-2020 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program 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 General Public License for more details.
14 You should have received a copy of the GNU 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;