libssh2_version(3)
π libssh2_version(3) β the libssh2 manual, bestie edition π
okay so this is a page from the libssh2 manual, and today's main character is libssh2_version β¨
πΈ NAME πΈ
libssh2_version β bestie, it literally just returns the libssh2 version number π
π SYNOPSIS π
#include <libssh2.h>
const char *
libssh2_version(int required_version);
π¦ DESCRIPTION π¦
okay so here's the tea β if required_version is lower than or equal to the version number of the libssh2 that's actually in use, then boom π₯ you get the version number of libssh2 back, as a pointer to a zero terminated string. iconic behaviour, no notes.
and the required_version you pass in? it should be the version number as constructed by the LIBSSH2_VERSION_NUM define over in the libssh2.h public header file π and that thing is a 24 bit number in the 0xMMmmpp format, periodt. so like:
MMβ major number πmmβ minor number β¨ppβ patch number π©Ή
π RETURN VALUE π
you get the version number of libssh2 back as a pointer to a zero terminated string π β¦ OR you get NULL if the required_version is not fulfilled π that's it, that's the whole vibe check.
π₯ EXAMPLE π₯
say you wanna make sure you're running with the correct libssh2 version β do this, bestie:
if(!libssh2_version(LIBSSH2_VERSION_NUM)) {
fprintf(stderr, "Runtime libssh2 version too old.");
exit(1);
}
and if you just wanna unconditionally get the version number, no gatekeeping, no conditions, just vibes:
printf("libssh2 version: %s", libssh2_version(0));
π AVAILABILITY π
this function was added in libssh2 1.1 π«Ά and in previous versions there was literally no way to extract this info at run-time. like, none. tragic, honestly. π
β SEE ALSO β
(this page doesn't list any SEE ALSO references, bestie β it's a short one, we keep it cute π)
π quick reminder: ifrequired_versionisn't fulfilled you getNULL, so fr fr check your return value before you go dereferencing it. your future self will thank you π«Ά
and that's the whole page!! π this was from the libssh2 manual, page libssh2_version(3), dated 23 Feb 2009 β yeah she's an old queen but she still slays π mwah, bye bestie π§β¨π
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms