mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-25 06:50:41 -05:00
windows/storage.c: factor out low-level Registry access.
All the fiddly business where you have to check that a thing exists, make sure of its type, find its size, allocate some memory, and then read it again properly (or, alternatively, loop round dealing with ERROR_MORE_DATA) just doesn't belong at every call site. It's crying out to be moved out into some separate utility functions that present a more ergonomic API, so that the code that decides _which_ Registry entries to read and what to do with them can concentrate on that. So I've written a fresh set of registry API wrappers in windows/utils, and simplified windows/storage.c as a result. The jump-list handling code in particular is almost legible now!
This commit is contained in:
@ -716,7 +716,20 @@ char *get_jumplist_registry_entries(void);
|
||||
#define CLIPUI_DEFAULT_INS CLIPUI_EXPLICIT
|
||||
|
||||
/* In utils */
|
||||
char *registry_get_string(HKEY root, const char *path, const char *leaf);
|
||||
HKEY open_regkey_fn(bool create, HKEY base, const char *path, ...);
|
||||
#define open_regkey(create, base, ...) \
|
||||
open_regkey_fn(create, base, __VA_ARGS__, (const char *)NULL)
|
||||
void close_regkey(HKEY key);
|
||||
void del_regkey(HKEY key, const char *name);
|
||||
char *enum_regkey(HKEY key, int index);
|
||||
bool get_reg_dword(HKEY key, const char *name, DWORD *out);
|
||||
bool put_reg_dword(HKEY key, const char *name, DWORD value);
|
||||
char *get_reg_sz(HKEY key, const char *name);
|
||||
bool put_reg_sz(HKEY key, const char *name, const char *str);
|
||||
strbuf *get_reg_multi_sz(HKEY key, const char *name);
|
||||
bool put_reg_multi_sz(HKEY key, const char *name, strbuf *str);
|
||||
|
||||
char *get_reg_sz_simple(HKEY key, const char *name, const char *leaf);
|
||||
|
||||
/* In cliloop.c */
|
||||
typedef bool (*cliloop_pre_t)(void *vctx, const HANDLE **extra_handles,
|
||||
|
Reference in New Issue
Block a user