Branch data Line data Source code
1 : : /* version.c - implementation of version checking functions
2 : : Copyright (C) 2011 Simon Josefsson
3 : :
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 3 of the License, or
7 : : (at your option) any later version.
8 : :
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.
13 : :
14 : : You should have received a copy of the GNU General Public License
15 : : along with this program. If not, see <http://www.gnu.org/licenses/>.
16 : : */
17 : :
18 : : #include <config.h>
19 : :
20 : : #include "idn2.h"
21 : :
22 : : #include <string.h> /* strverscmp */
23 : :
24 : : /**
25 : : * idn2_check_version:
26 : : * @req_version: version string to compare with, or NULL.
27 : : *
28 : : * Check IDN2 library version. This function can also be used to read
29 : : * out the version of the library code used. See %IDN2_VERSION for a
30 : : * suitable @req_version string, it corresponds to the idn2.h header
31 : : * file version. Normally these two version numbers match, but if you
32 : : * are using an application built against an older libidn2 with a
33 : : * newer libidn2 shared library they will be different.
34 : : *
35 : : * Return value: Check that the version of the library is at
36 : : * minimum the one given as a string in @req_version and return the
37 : : * actual version string of the library; return NULL if the
38 : : * condition is not met. If NULL is passed to this function no
39 : : * check is done and only the version string is returned.
40 : : **/
41 : : const char *
42 : 3 : idn2_check_version (const char *req_version)
43 : : {
44 [ + + ][ + + ]: 3 : if (!req_version || strverscmp (req_version, IDN2_VERSION) <= 0)
45 : 2 : return IDN2_VERSION;
46 : :
47 : 3 : return NULL;
48 : : }
|