libssh2_knownhost_writeline(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_knownhost_writeline(3) ✨

okay so bestie, welcome to the libssh2 manual, and today's main character is libssh2_knownhost_writeline πŸ’…


🌸 NAME 🌸

libssh2_knownhost_writeline β€” convert a known host to a line for storage πŸ¦‹


πŸ’– SYNOPSIS πŸ’–

#include <libssh2.h>

int
libssh2_knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
                            struct libssh2_knownhost *known,
                            char *buffer, size_t buflen,
                            size_t *outlen,
                            int type);

πŸŽ€ DESCRIPTION πŸŽ€

so this function takes one single known host and turns it into one single line of output that you can store, using the output format you picked with type. it's giving "glow up from struct to text" ✨

  • known β€” this identifies which particular known host we're talking about, iykyk πŸ‘‘
  • buffer β€” this points to an allocated buffer 🫢
  • buflen β€” this is the size of the buffer. and bestie, check the RETURN VALUE section for the tea on sizing πŸ‘€
  • outlen β€” this must be a pointer to a size_t variable, and it's gonna get the output length of the stored data chunk. important: that number does NOT include the trailing zero! periodt πŸ’€
  • type β€” this specifies what file type it is, and LIBSSH2_KNOWNHOST_FILE_OPENSSH is the only currently supported format. no other options, that's the whole menu fr fr 🌈

πŸ”₯ RETURN VALUE πŸ”₯

returns a regular libssh2 error code, where negative values are error codes and 0 indicates success πŸ’š

now, if the buffer you handed over is deemed too small to fit the data libssh2 wants to store in it, you'll get LIBSSH2_ERROR_BUFFER_TOO_SMALL back 😭. the application is then advised to call the function again with a larger buffer. and when that happens, the outlen size will then hold the requested size, so you know exactly how much room to give it next time. not me getting rejected by a buffer πŸ’…


⭐ AVAILABILITY ⭐

added in libssh2 1.2 β€” vintage, but make it iconic πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹


okay that's the whole page bestie, go forth and write those known host lines 🌸🫢

libssh2 β€” 28 May 2009 πŸ’– this manual page is brought to you by the libssh2 girlies, slay responsibly ✨