Subject: Re: libssh2_knownhost_*

Re: libssh2_knownhost_*

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Thu, 28 May 2009 14:24:28 +0100

2009/5/28 Daniel Stenberg <daniel_at_haxx.se>:
>
> I've just pushed my initial 7 man pages for the known hosts API I've been
> working on recently. I'm very interested in comments and feedback on its
> functionality.
>
> The seven functions are:
>
>        libssh2_knownhost_add        - adds a known host
>        libssh2_knownhost_check      - checks a host
>        libssh2_knownhost_del        - deletes a known host
>        libssh2_knownhost_dumpfile   - writes all known hosts to file
>        libssh2_knownhost_get        - extract/iterate over known hosts
>        libssh2_knownhost_init       - init a known host collection
>        libssh2_knownhost_parsefile  - read/parse a known_hosts file

Thanks for all the great work Daniel. I'm very pleased to see this
API appear. After a quick skim of the code a few issues came to mind:

libssh2_knownhost_dumpfile: The name of this function implies
something related to debugging but it isn't. I would suggest
something like knownhost_persistfile, knownhost_writefile, or
knownhost_savefile. 'persist' has the advantage of making it appear
next to its sibling 'parse' when ordered alphabetically ;)

filename parameters: The knownhost_*file functions take a const char*
filename parameter which they proceed to open and use. While this is
common in APIs, I would argue that it is better to take a FILE* and
allow the client code to open the file however it sees fit. The FILE
interface was purposely designed to allow any 'file-like object' to be
used as a regular disk file. An example of this is the glibc fmemopen
function that creates a memory-backed file.

Whole-file parse/writeback: As I understand it, using the API goes roughly:
    init parsefile (add | del | check | get)* dumpfile
My worry here is that we will lose information between parsefile and
dumpfile such as the order of the existing entries and any comment
strings (iirc, these are allowed after #). In other words:
    file != dumpfile(parsefile(file))
I've not had time to study the code in detail so I apologise if this
is already being taken care of.

Alex Lamaison

--
http://swish.sourceforge.net
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-05-28