introducing libssh2_knownhost_get() to the public API

This commit is contained in:
Daniel Stenberg 2009-05-27 16:00:52 +02:00
parent d965dda027
commit eaa95e0331
2 changed files with 55 additions and 0 deletions

View File

@ -794,6 +794,24 @@ LIBSSH2_API int
libssh2_knownhost_parsefile(LIBSSH2_KNOWNHOSTS *hosts,
const char *filename, int type);
/*
* libssh2_knownhost_get()
*
* Traverse the internal list of known hosts. Pass NULL to 'prev' to get
* the first one. Or pass a poiner to the previously returned one to get the
* next.
*
* Returns:
* 0 if a fine host was stored in 'store'
* 1 if end of hosts
* [negative] on errors
*/
LIBSSH2_API int
libssh2_knownhost_get(LIBSSH2_KNOWNHOSTS *hosts,
struct libssh2_knownhost *store,
struct libssh2_knownhost *prev);
/* NOTE NOTE NOTE
libssh2_trace() has no function in builds that aren't built with debug
enabled

View File

@ -562,3 +562,40 @@ libssh2_knownhost_parsefile(LIBSSH2_KNOWNHOSTS *hosts,
return -1;
return num;
}
/*
* libssh2_knownhost_get()
*
* Traverse the internal list of known hosts. Pass NULL to 'prev' to get
* the first one.
*
* Returns:
* 0 if a fine host was stored in 'store'
* 1 if end of hosts
* [negative] on errors
*/
LIBSSH2_API int
libssh2_knownhost_get(LIBSSH2_KNOWNHOSTS *hosts,
struct libssh2_knownhost *store,
struct libssh2_knownhost *oprev)
{
struct known_host *node;
if(oprev && oprev->node) {
/* we have a starting point */
struct known_host *prev = oprev->node;
/* get the next node in the list */
node = _libssh2_list_next(&prev->node);
}
else
node = _libssh2_list_first(&hosts->head);
if(!node)
/* no (more) node */
return 1;
knownhost_to_external(node, store);
return 0;
}