2 * Copyright (c) 2008, Dave Korn.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * This is the header for the ExtraKeysSetting class, which persists and reads
13 * in (and saves) extra public DSA signing keys for the verification process.
14 * It stores them all in a contiguous memory buffer. Each is one line of
15 * ASCII text terminated by LF. THERE IS NO NUL-TERMINATION HERE, TAKE CARE!
16 * The buffer is sized to the exact size of the content including the terminating
17 * LF of the last entry. There is no zero after it. After reading the file,
18 * any partial last line is truncated.
20 * Written by Dave Korn <dave.korn.cygwin@gmail.com>
24 #ifndef SETUP_KEYSSETTING_H
25 #define SETUP_KEYSSETTING_H
29 class ExtraKeysSetting
35 static ExtraKeysSetting
*global
;
37 // Loads keys from the "extrakeys" user setting.
39 // Saves them back again.
41 static ExtraKeysSetting
& instance () {return *global
;}
44 // Extend (or shrink) allocated buffer. Leaves it in a
45 // potentially invalid state until count_keys is called
46 // (or the bufsize is made valid by filling it up and
47 // the numkeys count adjusted likewise).
48 void realloc (size_t newbufsize
);
49 // Count keys and size buffer after loading.
50 size_t count_keys (void);
51 // Add a key without testing for existence
52 void add_unique_key (const char *key
);
55 // Number of keys in buffer.
56 size_t num_keys (void);
57 // Get pointer to LF-terminated Nth. key string and len.
58 const char *get_key (size_t num
, size_t *size
);
59 // Add a key to the buffer (if not already present).
60 void add_key (const char *key
);
65 #endif /* SETUP_CONNECTIONSETTING_H */