1 /* check-version.h --- Check version string compatibility. 2 Copyright (C) 1998-2006, 2008-2021 Free Software Foundation, Inc. 3 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. 8 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. 13 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/>. */ 16 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. */ 20 21 #include <config.h> 22 23 #include <stddef.h> 24 #include <string.h> 25 26 /* Get specification. */ 27 #include "check-version.h" 28 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. 34 */ 35 const char * 36 check_version (const char *req_version) /* */ 37 { 38 if (!req_version || strverscmp (req_version, VERSION) <= 0) 39 return VERSION; 40 41 return NULL; 42 }