Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

storage.h

00001 /*
00002  * storage.h: interface defining functions for storage and recovery
00003  * of PuTTY's persistent data.
00004  */
00005 
00006 #ifndef PUTTY_STORAGE_H
00007 #define PUTTY_STORAGE_H
00008 
00009 /* ----------------------------------------------------------------------
00010  * Functions to save and restore PuTTY sessions. Note that this is
00011  * only the low-level code to do the reading and writing. The
00012  * higher-level code that translates a Config structure into a set
00013  * of (key,value) pairs is elsewhere, since it doesn't (mostly)
00014  * change between platforms.
00015  */
00016 
00017 /*
00018  * Write a saved session. The caller is expected to call
00019  * open_setting_w() to get a `void *' handle, then pass that to a
00020  * number of calls to write_setting_s() and write_setting_i(), and
00021  * then close it using close_settings_w(). At the end of this call
00022  * sequence the settings should have been written to the PuTTY
00023  * persistent storage area.
00024  *
00025  * A given key will be written at most once while saving a session.
00026  * Keys may be up to 255 characters long.  String values have no length
00027  * limit.
00028  */
00029 void *open_settings_w(char *sessionname);
00030 void write_setting_s(void *handle, char *key, char *value);
00031 void write_setting_i(void *handle, char *key, int value);
00032 void close_settings_w(void *handle);
00033 
00034 /*
00035  * Read a saved session. The caller is expected to call
00036  * open_setting_r() to get a `void *' handle, then pass that to a
00037  * number of calls to read_setting_s() and read_setting_i(), and
00038  * then close it using close_settings_r().
00039  * 
00040  * read_setting_s() writes into the provided buffer and returns a
00041  * pointer to the same buffer.
00042  * 
00043  * If a particular string setting is not present in the session,
00044  * read_setting_s() can return NULL, in which case the caller
00045  * should invent a sensible default. If an integer setting is not
00046  * present, read_setting_i() returns its provided default.
00047  */
00048 void *open_settings_r(char *sessionname);
00049 char *read_setting_s(void *handle, char *key, char *buffer, int buflen);
00050 int read_setting_i(void *handle, char *key, int defvalue);
00051 void close_settings_r(void *handle);
00052 
00053 /*
00054  * Delete a whole saved session.
00055  */
00056 void del_settings(char *sessionname);
00057 
00058 /*
00059  * Enumerate all saved sessions.
00060  */
00061 void *enum_settings_start(void);
00062 char *enum_settings_next(void *handle, char *buffer, int buflen);
00063 void enum_settings_finish(void *handle);
00064 
00065 /* ----------------------------------------------------------------------
00066  * Functions to access PuTTY's host key database.
00067  */
00068 
00069 /*
00070  * See if a host key matches the database entry. Return values can
00071  * be 0 (entry matches database), 1 (entry is absent in database),
00072  * or 2 (entry exists in database and is different).
00073  */
00074 int verify_host_key(char *hostname, int port, char *keytype, char *key);
00075 
00076 /*
00077  * Write a host key into the database, overwriting any previous
00078  * entry that might have been there.
00079  */
00080 void store_host_key(char *hostname, int port, char *keytype, char *key);
00081 
00082 /* ----------------------------------------------------------------------
00083  * Functions to access PuTTY's random number seed file.
00084  */
00085 
00086 typedef void (*noise_consumer_t) (void *data, int len);
00087 
00088 /*
00089  * Read PuTTY's random seed file and pass its contents to a noise
00090  * consumer function.
00091  */
00092 void read_random_seed(noise_consumer_t consumer);
00093 
00094 /*
00095  * Write PuTTY's random seed file from a given chunk of noise.
00096  */
00097 void write_random_seed(void *data, int len);
00098 
00099 /* ----------------------------------------------------------------------
00100  * Cleanup function: remove all of PuTTY's persistent state.
00101  */
00102 void cleanup_all(void);
00103 
00104 #endif

Generated on Sun Feb 9 13:01:29 2003 for PuTTY by doxygen1.2.18