mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
common,w32: New function read_w32_reg_string.
* common/w32-reg.c (read_w32_reg_string): New. * common/t-w32-reg.c (test_read_registry): Add another test.
This commit is contained in:
parent
6ee01c1d26
commit
6c6c404883
3 changed files with 74 additions and 18 deletions
|
@ -226,5 +226,53 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
|
|||
#endif /*!HAVE_W32CE_SYSTEM*/
|
||||
}
|
||||
|
||||
/* Compact version of read_w32_registry_string. This version expects
|
||||
* a single string as key described here using an example:
|
||||
*
|
||||
* HKCU\Software\GNU\GnuPG:HomeDir
|
||||
*
|
||||
* HKCU := the class, other supported classes are HKLM, HKCR, HKU, and
|
||||
* HKCC. If no class is given and the string thus starts with
|
||||
* a backslash HKCU with a fallback to HKLM is used.
|
||||
* Software\GNU\GnuPG := The actual key.
|
||||
* HomeDir := the name of the item. The name is optional to use the default
|
||||
* value.
|
||||
*
|
||||
* Note that the first backslash and the first colon act as delimiters.
|
||||
*
|
||||
* Returns a malloced string or NULL if not found.
|
||||
*/
|
||||
char *
|
||||
read_w32_reg_string (const char *key_arg)
|
||||
{
|
||||
char *key;
|
||||
char *p1, *p2;
|
||||
char *result;
|
||||
|
||||
if (!key_arg)
|
||||
return NULL;
|
||||
key = xtrystrdup (key_arg);
|
||||
if (!key)
|
||||
{
|
||||
log_info ("warning: malloc failed while reading registry key\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p1 = strchr (key, '\\');
|
||||
if (!p1)
|
||||
{
|
||||
xfree (key);
|
||||
return NULL;
|
||||
}
|
||||
*p1++ = 0;
|
||||
p2 = strchr (p1, ':');
|
||||
if (p2)
|
||||
*p2++ = 0;
|
||||
|
||||
result = read_w32_registry_string (*key? key : NULL, p1, p2);
|
||||
xfree (key);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue