From 7877f32cbc009c87b5a294477bbd09bc8f0f8b05 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 26 May 2025 18:09:59 +0200 Subject: [PATCH] [locale,keyboard] use new JSON config reader --- libfreerdp/locale/keyboard_layout.c | 49 ++--------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index a7a3008fe..6d3a117dd 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -924,7 +924,7 @@ static BOOL load_layout_file(void) if (!fp) goto end; (void)fprintf(fp, "%s", str); - fclose(fp); + (void)fclose(fp); } end: free(str); @@ -1006,54 +1006,9 @@ static void clear_layout_tables(void) static WINPR_JSON* load_layouts_from_file(const char* filename) { - INT64 jstrlen = 0; - char* jstr = NULL; - WINPR_JSON* json = NULL; - FILE* fp = winpr_fopen(filename, "r"); - if (!fp) - { - WLog_WARN(TAG, "resource file '%s' does not exist or is not readable", filename); - return NULL; - } - - if (_fseeki64(fp, 0, SEEK_END) < 0) - { - WLog_WARN(TAG, "resource file '%s' seek failed", filename); - goto end; - } - jstrlen = _ftelli64(fp); - if (jstrlen < 0) - { - WLog_WARN(TAG, "resource file '%s' invalid length %" PRId64, filename, jstrlen); - goto end; - } - if (_fseeki64(fp, 0, SEEK_SET) < 0) - { - WLog_WARN(TAG, "resource file '%s' seek failed", filename); - goto end; - } - - jstr = calloc((size_t)jstrlen + 1, sizeof(char)); - if (!jstr) - { - WLog_WARN(TAG, "resource file '%s' failed to allocate buffer of size %" PRId64, filename, - jstrlen); - goto end; - } - - if (fread(jstr, (size_t)jstrlen, sizeof(char), fp) != 1) - { - WLog_WARN(TAG, "resource file '%s' failed to read buffer of size %" PRId64, filename, - jstrlen); - goto end; - } - - json = WINPR_JSON_ParseWithLength(jstr, (size_t)jstrlen); + WINPR_JSON* json = WINPR_JSON_ParseFromFile(filename); if (!json) WLog_WARN(TAG, "resource file '%s' is not a valid JSON file", filename); -end: - fclose(fp); - free(jstr); return json; }