/src/libidn2/lib/version.c
Line | Count | Source |
1 | | /* version.c - implementation of version checking functions |
2 | | Copyright (C) 2011-2025 Simon Josefsson |
3 | | |
4 | | Libidn2 is free software: you can redistribute it and/or modify it |
5 | | under the terms of either: |
6 | | |
7 | | * the GNU Lesser General Public License as published by the Free |
8 | | Software Foundation; either version 3 of the License, or (at |
9 | | your option) any later version. |
10 | | |
11 | | or |
12 | | |
13 | | * the GNU General Public License as published by the Free |
14 | | Software Foundation; either version 2 of the License, or (at |
15 | | your option) any later version. |
16 | | |
17 | | or both in parallel, as here. |
18 | | |
19 | | This program is distributed in the hope that it will be useful, |
20 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | | GNU General Public License for more details. |
23 | | |
24 | | You should have received copies of the GNU General Public License and |
25 | | the GNU Lesser General Public License along with this program. If |
26 | | not, see <http://www.gnu.org/licenses/>. |
27 | | */ |
28 | | |
29 | | #include <config.h> |
30 | | |
31 | | #include "idn2.h" |
32 | | |
33 | | #include <string.h> /* strverscmp */ |
34 | | #include <version-etc.h> /* version_etc_copyright */ |
35 | | |
36 | | #ifdef __cplusplus |
37 | | extern // define a global const variable in C++, C doesn't need it. |
38 | | #endif |
39 | | const char version_etc_copyright[] = |
40 | | /* Do *not* mark this string for translation */ |
41 | | "Copyright (C) 2011-2025 Simon Josefsson"; |
42 | | |
43 | | /** |
44 | | * idn2_check_version: |
45 | | * @req_version: version string to compare with, or NULL. |
46 | | * |
47 | | * Check IDN2 library version. This function can also be used to read |
48 | | * out the version of the library code used. See %IDN2_VERSION for a |
49 | | * suitable @req_version string, it corresponds to the idn2.h header |
50 | | * file version. Normally these two version numbers match, but if you |
51 | | * are using an application built against an older libidn2 with a |
52 | | * newer libidn2 shared library they will be different. |
53 | | * |
54 | | * Return value: Check that the version of the library is at |
55 | | * minimum the one given as a string in @req_version and return the |
56 | | * actual version string of the library; return NULL if the |
57 | | * condition is not met. If NULL is passed to this function no |
58 | | * check is done and only the version string is returned. |
59 | | **/ |
60 | | const char * |
61 | | idn2_check_version (const char *req_version) |
62 | 880 | { |
63 | 880 | if (!req_version || strverscmp (req_version, IDN2_VERSION) <= 0) |
64 | 142 | return IDN2_VERSION; |
65 | | |
66 | 738 | return NULL; |
67 | 880 | } |