diff options
author | Simon Tatham <anakin@pobox.com> | 2000-09-27 19:21:04 +0400 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2000-09-27 19:21:04 +0400 |
commit | aad0a52dfb453b77fa6c0b36fadf16ae4b19a30c (patch) | |
tree | d8ee39ce45052ad31cccac95033c77828818c75a /storage.h | |
parent | 0fed43e9f4974570791bdb8a5d61631a4e84d1b0 (diff) |
Rationalised host key storage. Also started code reorg: persistent-state
routines have been moved out into a replaceable module winstore.c.
[originally from svn r639]
Diffstat (limited to 'storage.h')
-rw-r--r-- | storage.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/storage.h b/storage.h new file mode 100644 index 00000000..b5ac3b51 --- /dev/null +++ b/storage.h @@ -0,0 +1,88 @@ +/* + * storage.h: interface defining functions for storage and recovery + * of PuTTY's persistent data. + */ + +#ifndef PUTTY_STORAGE_H +#define PUTTY_STORAGE_H + +/* ---------------------------------------------------------------------- + * Functions to save and restore PuTTY sessions. Note that this is + * only the low-level code to do the reading and writing. The + * higher-level code that translates a Config structure into a set + * of (key,value) pairs is elsewhere, since it doesn't (mostly) + * change between platforms. + */ + +/* + * Write a saved session. The caller is expected to call + * open_setting_w() to get a `void *' handle, then pass that to a + * number of calls to write_setting_s() and write_setting_i(), and + * then close it using close_settings_w(). At the end of this call + * sequence the settings should have been written to the PuTTY + * persistent storage area. + */ +void *open_settings_w(char *sessionname); +void write_setting_s(void *handle, char *key, char *value); +void write_setting_i(void *handle, char *key, int value); +void *close_settings_w(void *handle); + +/* + * Read a saved session. The caller is expected to call + * open_setting_r() to get a `void *' handle, then pass that to a + * number of calls to read_setting_s() and read_setting_i(), and + * then close it using close_settings_r(). + * + * read_setting_s() writes into the provided buffer and returns a + * pointer to the same buffer. + * + * If a particular string setting is not present in the session, + * read_setting_s() can return NULL, in which case the caller + * should invent a sensible default. If an integer setting is not + * present, read_setting_i() returns its provided default. + */ +void *open_settings_r(char *sessionname); +char *read_setting_s(void *handle, char *key, char *buffer, int buflen); +int read_setting_i(void *handle, char *key, int defvalue); +void *close_settings_r(void *handle); + +/* ---------------------------------------------------------------------- + * Functions to access PuTTY's host key database. + */ + +/* + * See if a host key matches the database entry. Return values can + * be 0 (entry matches database), 1 (entry is absent in database), + * or 2 (entry exists in database and is different). + */ +int verify_host_key(char *hostname, char *keytype, char *key); + +/* + * Write a host key into the database, overwriting any previous + * entry that might have been there. + */ +void store_host_key(char *hostname, char *keytype, char *key); + +/* ---------------------------------------------------------------------- + * Functions to access PuTTY's random number seed file. + */ + +typedef void (*noise_consumer_t)(void *data, size_t len); + +/* + * Read PuTTY's random seed file and pass its contents to a noise + * consumer function. + */ +void read_random_seed(noise_consumer_t consumer); + +/* + * Write PuTTY's random seed file from a given chunk of noise. + */ +void write_random_seed(void *data, size_t len); + +/* ---------------------------------------------------------------------- + * Cleanup function: remove all of PuTTY's persistent state. + */ +void cleanup_all(void); + +#endif |