1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-13 17:17:37 -05:00

Allow import.c to read from a BinarySource.

Like sshpubk.c before it, the loading side of import.c now works by
first slurping the whole input file into a LoadedFile structure, and
then using the BinarySource system to parse the file contents entirely
in memory.

The old API is still present and works the same as ever, but now we
also provide a secondary API that can import a foreign key file from a
BinarySource.

This is rather a superficial conversion: I've replaced all calls to
fgetline() with a local static function bsgetline() which presents
more or less the same interface for a BinarySource: that is, it still
returns a dynamically allocated string containing the line of text, so
that the followup code could change as little as possible. It would be
nice to come back in future and modernise this code to use ptrlens
throughout, saving all the unnecessary allocations.
This commit is contained in:
Simon Tatham
2020-02-02 11:58:24 +00:00
parent 5db2f4ca7e
commit 36d214c50b
3 changed files with 92 additions and 79 deletions

View File

@ -1019,7 +1019,7 @@ char *mkstr(ptrlen pl)
bool strstartswith(const char *s, const char *t)
{
return !memcmp(s, t, strlen(t));
return !strncmp(s, t, strlen(t));
}
bool strendswith(const char *s, const char *t)