Use a consistent style for including <config.h>.
[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 Free
3    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 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <stddef.h>
28 #include <strverscmp.h>
29
30 /* Get specification. */
31 #include "check-version.h"
32
33 /* Check that the the version of the library (i.e., the CPP symbol
34  * VERSION) is at minimum the requested one in REQ_VERSION (typically
35  * found in a header file) and return the version string.  Return NULL
36  * if the condition is not satisfied.  If a NULL is passed to this
37  * function, no check is done, but the version string is simply
38  * returned.
39  */
40 const char *
41 check_version (const char *req_version)
42 {
43   if (!req_version || strverscmp (req_version, VERSION) <= 0)
44     return VERSION;
45
46   return NULL;
47 }