aboutsummaryrefslogtreecommitdiff
path: root/tools/plink/winstore.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-24 16:52:31 +0100
committermarha <marha@users.sourceforge.net>2012-01-24 16:52:31 +0100
commitdce7b34b9f70d28161082e6187c5cb6ea4079060 (patch)
treeb3b63b028dfc4e4853f71339390eea6fb3f6cc24 /tools/plink/winstore.c
parent6ba4c534507676abe7d7ac415cb113cd40953925 (diff)
parent6039fd0faf73c9d6c5b2abf9d824734218ec5eee (diff)
downloadvcxsrv-dce7b34b9f70d28161082e6187c5cb6ea4079060.tar.gz
vcxsrv-dce7b34b9f70d28161082e6187c5cb6ea4079060.tar.bz2
vcxsrv-dce7b34b9f70d28161082e6187c5cb6ea4079060.zip
Merge remote-tracking branch 'origin/released'
Conflicts: tools/plink/sshbn.c
Diffstat (limited to 'tools/plink/winstore.c')
-rw-r--r--tools/plink/winstore.c76
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)