diff options
author | marha <marha@users.sourceforge.net> | 2012-01-24 16:46:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-01-24 16:46:55 +0100 |
commit | 6039fd0faf73c9d6c5b2abf9d824734218ec5eee (patch) | |
tree | 88f66f9d7c4763f206de6043ef45c63b94472690 /tools/plink/winstore.c | |
parent | b683b8f5675e280a6dd4ab82d6b9394182798b55 (diff) | |
download | vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.tar.gz vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.tar.bz2 vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.zip |
Update to putty 9388
Diffstat (limited to 'tools/plink/winstore.c')
-rw-r--r-- | tools/plink/winstore.c | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/tools/plink/winstore.c b/tools/plink/winstore.c index 13ee184a5..f152b8f69 100644 --- a/tools/plink/winstore.c +++ b/tools/plink/winstore.c @@ -150,17 +150,26 @@ void *open_settings_r(const char *sessionname) return (void *) sesskey;
}
-char *read_setting_s(void *handle, const char *key, char *buffer, int buflen)
+char *read_setting_s(void *handle, const char *key)
{
DWORD type, size;
- size = buflen;
+ char *ret;
- if (!handle ||
- RegQueryValueEx((HKEY) handle, key, 0,
- &type, buffer, &size) != ERROR_SUCCESS ||
+ if (!handle)
+ return NULL;
+
+ /* Find out the type and size of the data. */
+ if (RegQueryValueEx((HKEY) handle, key, 0,
+ &type, NULL, &size) != ERROR_SUCCESS ||
+ type != REG_SZ)
+ return NULL;
+
+ ret = snewn(size+1, char);
+ if (RegQueryValueEx((HKEY) handle, key, 0,
+ &type, ret, &size) != ERROR_SUCCESS ||
type != REG_SZ) return NULL;
- else
- return buffer;
+
+ return ret;
}
int read_setting_i(void *handle, const char *key, int defvalue)
@@ -177,53 +186,64 @@ int read_setting_i(void *handle, const char *key, int defvalue) return val;
}
-int read_setting_fontspec(void *handle, const char *name, FontSpec *result)
+FontSpec *read_setting_fontspec(void *handle, const char *name)
{
char *settingname;
- FontSpec ret;
+ char *fontname;
+ int isbold, height, charset;
+
+ fontname = read_setting_s(handle, name);
+ if (!fontname)
+ return NULL;
- if (!read_setting_s(handle, name, ret.name, sizeof(ret.name)))
- return 0;
settingname = dupcat(name, "IsBold", NULL);
- ret.isbold = read_setting_i(handle, settingname, -1);
+ isbold = read_setting_i(handle, settingname, -1);
sfree(settingname);
- if (ret.isbold == -1) return 0;
+ if (isbold == -1) return NULL;
+
settingname = dupcat(name, "CharSet", NULL);
- ret.charset = read_setting_i(handle, settingname, -1);
+ charset = read_setting_i(handle, settingname, -1);
sfree(settingname);
- if (ret.charset == -1) return 0;
+ if (charset == -1) return NULL;
+
settingname = dupcat(name, "Height", NULL);
- ret.height = read_setting_i(handle, settingname, INT_MIN);
+ height = read_setting_i(handle, settingname, INT_MIN);
sfree(settingname);
- if (ret.height == INT_MIN) return 0;
- *result = ret;
- return 1;
+ if (height == INT_MIN) return NULL;
+
+ return fontspec_new(fontname, isbold, height, charset);
}
-void write_setting_fontspec(void *handle, const char *name, FontSpec font)
+void write_setting_fontspec(void *handle, const char *name, FontSpec *font)
{
char *settingname;
- write_setting_s(handle, name, font.name);
+ write_setting_s(handle, name, font->name);
settingname = dupcat(name, "IsBold", NULL);
- write_setting_i(handle, settingname, font.isbold);
+ write_setting_i(handle, settingname, font->isbold);
sfree(settingname);
settingname = dupcat(name, "CharSet", NULL);
- write_setting_i(handle, settingname, font.charset);
+ write_setting_i(handle, settingname, font->charset);
sfree(settingname);
settingname = dupcat(name, "Height", NULL);
- write_setting_i(handle, settingname, font.height);
+ write_setting_i(handle, settingname, font->height);
sfree(settingname);
}
-int read_setting_filename(void *handle, const char *name, Filename *result)
+Filename *read_setting_filename(void *handle, const char *name)
{
- return !!read_setting_s(handle, name, result->path, sizeof(result->path));
+ char *tmp = read_setting_s(handle, name);
+ if (tmp) {
+ Filename *ret = filename_from_str(tmp);
+ sfree(tmp);
+ return ret;
+ } else
+ return NULL;
}
-void write_setting_filename(void *handle, const char *name, Filename result)
+void write_setting_filename(void *handle, const char *name, Filename *result)
{
- write_setting_s(handle, name, result.path);
+ write_setting_s(handle, name, result->path);
}
void close_settings_r(void *handle)
|