-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from Gottox/add/header-version-definition
utils: add functions to get the current version of the library
- Loading branch information
Showing
7 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ headers = files( | |
'sqsh_posix.h', | ||
'sqsh_table.h', | ||
'sqsh_tree.h', | ||
'sqsh_utils.h', | ||
'sqsh_xattr.h', | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/****************************************************************************** | ||
* * | ||
* Copyright (c) 2023-2024, Enno Boland <[email protected]> * | ||
* * | ||
* Redistribution and use in source and binary forms, with or without * | ||
* modification, are permitted provided that the following conditions are * | ||
* met: * | ||
* * | ||
* * Redistributions of source code must retain the above copyright notice, * | ||
* this list of conditions and the following disclaimer. * | ||
* * Redistributions in binary form must reproduce the above copyright * | ||
* notice, this list of conditions and the following disclaimer in the * | ||
* documentation and/or other materials provided with the distribution. * | ||
* * | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | ||
* * | ||
******************************************************************************/ | ||
|
||
/** | ||
* @author Enno Boland ([email protected]) | ||
* @file sqsh_utils.h | ||
*/ | ||
|
||
#ifndef SQSH_UTILS_H | ||
#define SQSH_UTILS_H | ||
|
||
#include "sqsh_common.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/*************************************** | ||
* utils/version.c | ||
*/ | ||
|
||
/** | ||
* @brief Get the version of the library that was used to compile the program as | ||
* a string. | ||
* | ||
* @return Version string | ||
*/ | ||
#define SQSH_VERSION "1.4.0" | ||
|
||
/** | ||
* @brief Get the major version of the library that was used to compile the | ||
* program. | ||
* | ||
* @return Major version | ||
*/ | ||
#define SQSH_VERSION_MAJOR 1 | ||
|
||
/** | ||
* @brief Get the minor version of the library that was used to compile the | ||
* program. | ||
* | ||
* @return Minor version | ||
*/ | ||
#define SQSH_VERSION_MINOR 4 | ||
|
||
/** | ||
* @brief Get the patch version of the library that was used to compile the | ||
* program. | ||
* | ||
* @return Patch version | ||
*/ | ||
#define SQSH_VERSION_PATCH 0 | ||
|
||
/** | ||
* @brief Get the version of the currently running library as a string. | ||
* | ||
* @return Version string | ||
*/ | ||
const char *sqsh_version(void); | ||
|
||
/** | ||
* @brief Get the major version of the currently running library. | ||
* | ||
* @return Major version | ||
*/ | ||
uint16_t sqsh_version_major(void); | ||
|
||
/** | ||
* @brief Get the minor version of the currently running library. | ||
* | ||
* @return Minor version | ||
*/ | ||
uint16_t sqsh_version_minor(void); | ||
|
||
/** | ||
* @brief Get the patch version of the currently running library. | ||
* | ||
* @return Patch version | ||
*/ | ||
uint16_t sqsh_version_patch(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* SQSH_UTILS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/****************************************************************************** | ||
* * | ||
* Copyright (c) 2023-2024, Enno Boland <[email protected]> * | ||
* * | ||
* Redistribution and use in source and binary forms, with or without * | ||
* modification, are permitted provided that the following conditions are * | ||
* met: * | ||
* * | ||
* * Redistributions of source code must retain the above copyright notice, * | ||
* this list of conditions and the following disclaimer. * | ||
* * Redistributions in binary form must reproduce the above copyright * | ||
* notice, this list of conditions and the following disclaimer in the * | ||
* documentation and/or other materials provided with the distribution. * | ||
* * | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | ||
* * | ||
******************************************************************************/ | ||
|
||
/** | ||
* @author Enno Boland ([email protected]) | ||
* @file version.c | ||
*/ | ||
|
||
#include <sqsh_utils.h> | ||
|
||
const char * | ||
sqsh_version(void) { | ||
return SQSH_VERSION; | ||
} | ||
|
||
uint16_t | ||
sqsh_version_major(void) { | ||
return SQSH_VERSION_MAJOR; | ||
} | ||
|
||
uint16_t | ||
sqsh_version_minor(void) { | ||
return SQSH_VERSION_MINOR; | ||
} | ||
|
||
uint16_t | ||
sqsh_version_patch(void) { | ||
return SQSH_VERSION_PATCH; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/****************************************************************************** | ||
* * | ||
* Copyright (c) 2023-2024, Enno Boland <[email protected]> * | ||
* * | ||
* Redistribution and use in source and binary forms, with or without * | ||
* modification, are permitted provided that the following conditions are * | ||
* met: * | ||
* * | ||
* * Redistributions of source code must retain the above copyright notice, * | ||
* this list of conditions and the following disclaimer. * | ||
* * Redistributions in binary form must reproduce the above copyright * | ||
* notice, this list of conditions and the following disclaimer in the * | ||
* documentation and/or other materials provided with the distribution. * | ||
* * | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | ||
* * | ||
******************************************************************************/ | ||
|
||
/** | ||
* @author Enno Boland ([email protected]) | ||
* @file nasty.c | ||
*/ | ||
|
||
#include <sqsh_utils.h> | ||
#include <utest.h> | ||
|
||
UTEST(version, version_defines_are_correct) { | ||
char *version = getenv("VERSION"); | ||
|
||
ASSERT_NE(NULL, version); | ||
ASSERT_STREQ(SQSH_VERSION, version); | ||
ASSERT_STREQ(SQSH_VERSION, sqsh_version()); | ||
|
||
int major, minor, patch; | ||
ASSERT_EQ(3, sscanf(version, "%d.%d.%d", &major, &minor, &patch)); | ||
|
||
ASSERT_EQ(SQSH_VERSION_MAJOR, major); | ||
ASSERT_EQ(SQSH_VERSION_MAJOR, sqsh_version_major()); | ||
ASSERT_EQ(SQSH_VERSION_MINOR, minor); | ||
ASSERT_EQ(SQSH_VERSION_MINOR, sqsh_version_minor()); | ||
ASSERT_EQ(SQSH_VERSION_PATCH, patch); | ||
ASSERT_EQ(SQSH_VERSION_PATCH, sqsh_version_patch()); | ||
} | ||
|
||
UTEST_MAIN() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters