libssh2_version(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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: if required_version isn't fulfilled you get NULL, 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 πŸ§šβœ¨πŸ’œ