Skip to content

Commit 3ab37cc

Browse files
committed
version UPDATE provide run-time version info
Fixes #2260
1 parent 014507d commit 3ab37cc

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/ly_common.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,23 @@
3737

3838
#include "compat.h"
3939
#include "tree_schema_internal.h"
40+
#include "version.h"
4041
#include "xml.h"
4142

43+
LIBYANG_API_DEF struct ly_version ly_version_so = {
44+
.major = LY_VERSION_MAJOR,
45+
.minor = LY_VERSION_MINOR,
46+
.micro = LY_VERSION_MICRO,
47+
.str = LY_VERSION
48+
};
49+
50+
LIBYANG_API_DEF struct ly_version ly_version_proj = {
51+
.major = LY_PROJ_VERSION_MAJOR,
52+
.minor = LY_PROJ_VERSION_MINOR,
53+
.micro = LY_PROJ_VERSION_MICRO,
54+
.str = LY_PROJ_VERSION
55+
};
56+
4257
void *
4358
ly_realloc(void *ptr, size_t size)
4459
{

src/version.h.in

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
22
* @file version.h
33
* @author Radek Krejci <[email protected]>
4+
* @author Michal Vasko <[email protected]>
45
* @brief libyang version definitions
56
*
6-
* Copyright (c) 2020 CESNET, z.s.p.o.
7+
* Copyright (c) 2020 - 2024 CESNET, z.s.p.o.
78
*
89
* This source code is licensed under BSD 3-Clause License (the "License").
910
* You may not use this file except in compliance with the License.
@@ -15,6 +16,10 @@
1516
#ifndef LY_VERSION_H_
1617
#define LY_VERSION_H_
1718

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
1823
#define LY_VERSION_MAJOR @LIBYANG_MAJOR_SOVERSION@ /**< libyang major version number */
1924
#define LY_VERSION_MINOR @LIBYANG_MINOR_SOVERSION@ /**< libyang minor version number */
2025
#define LY_VERSION_MICRO @LIBYANG_MICRO_SOVERSION@ /**< libyang micro version number */
@@ -25,4 +30,25 @@
2530
#define LY_PROJ_VERSION_MICRO @LIBYANG_MICRO_VERSION@ /**< project micro version number */
2631
#define LY_PROJ_VERSION "@LIBYANG_VERSION@" /**< project version string */
2732

33+
struct ly_version {
34+
uint32_t major; /**< Major version number */
35+
uint32_t minor; /**< Minor version number */
36+
uint32_t micro; /**< Micro version number */
37+
const char *str; /**< Version string */
38+
};
39+
40+
/**
41+
* @brief libyang SO version.
42+
*/
43+
LIBYANG_API_DECL extern struct ly_version ly_version_so;
44+
45+
/**
46+
* @brief libyang project version.
47+
*/
48+
LIBYANG_API_DECL extern struct ly_version ly_version_proj;
49+
50+
#ifdef __cplusplus
51+
}
52+
#endif
53+
2854
#endif /* LY_VERSION_H_ */

0 commit comments

Comments
 (0)