missing @item inside @itemize
[gnulib.git] / lib / check-version.c
1 /* check-version.h --- Check version string compatibility.
2    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008,
3    2009, 2010 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 /* Written by Simon Josefsson.  This interface is influenced by
20    gcry_check_version from Werner Koch's Libgcrypt.  Paul Eggert
21    suggested the use of strverscmp to simplify implementation. */
22
23 #include <config.h>
24
25 #include <stddef.h>
26 #include <string.h>
27
28 /* Get specification. */
29 #include "check-version.h"
30
31 /* Check that the version of the library (i.e., the CPP symbol VERSION)
32  * is at minimum the requested one in REQ_VERSION (typically found in
33  * a header file) and return the version string.  Return NULL if the
34  * condition is not satisfied.  If a NULL is passed to this function,
35  * no check is done, but the version string is simply returned.
36  */
37 const char *
38 check_version (const char *req_version)
39 {
40   if (!req_version || strverscmp (req_version, VERSION) <= 0)
41     return VERSION;
42
43   return NULL;
44 }