Added settings comparison function

This commit is contained in:
Armin Novak 2022-04-19 11:35:35 +02:00 committed by akallabeth
parent 83aaa4e575
commit 1f9916eba2
3 changed files with 185 additions and 0 deletions

View File

@ -1646,6 +1646,8 @@ extern "C"
FREERDP_API void freerdp_settings_free(rdpSettings* settings); FREERDP_API void freerdp_settings_free(rdpSettings* settings);
FREERDP_API void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings); FREERDP_API void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings);
FREERDP_API BOOL freerdp_settings_print_diff(wLog* log, DWORD level, const rdpSettings* src,
const rdpSettings* other);
FREERDP_API ADDIN_ARGV* freerdp_addin_argv_new(size_t argc, const char* argv[]); FREERDP_API ADDIN_ARGV* freerdp_addin_argv_new(size_t argc, const char* argv[]);
FREERDP_API ADDIN_ARGV* freerdp_addin_argv_clone(const ADDIN_ARGV* args); FREERDP_API ADDIN_ARGV* freerdp_addin_argv_clone(const ADDIN_ARGV* args);

View File

@ -499,6 +499,101 @@ BOOL freerdp_settings_clone_keys(rdpSettings* dst, const rdpSettings* src)
return TRUE; return TRUE;
} }
BOOL freerdp_settings_print_diff(wLog* log, DWORD level, const rdpSettings* settings,
const rdpSettings* other)
{
size_t x;
for (x = 0; x < ARRAYSIZE(settings_map); x++)
{
const struct settings_str_entry* cur = &settings_map[x];
switch (cur->type)
{
case 0: /* bool */
{
BOOL sval = freerdp_settings_get_bool(settings, cur->id);
BOOL cval = freerdp_settings_get_bool(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [BOOL]: %s -> %s", cur->str, sval ? "TRUE" : "FALSE",
cval ? "TRUE" : "FALSE");
}
break;
case 1: /* UINT16 */
{
UINT16 sval = freerdp_settings_get_uint16(settings, cur->id);
UINT16 cval = freerdp_settings_get_uint16(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [UINT16]: %" PRIu16 " -> %" PRIu16, cur->str, sval,
cval);
}
break;
case 2: /* INT16 */
{
INT16 sval = freerdp_settings_get_int16(settings, cur->id);
INT16 cval = freerdp_settings_get_int16(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [INT16]: %" PRId16 " -> %" PRId16, cur->str, sval,
cval);
}
break;
case 3: /* UINT32 */
{
UINT32 sval = freerdp_settings_get_uint32(settings, cur->id);
UINT32 cval = freerdp_settings_get_uint32(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [UINT32]: %" PRIu32 " -> %" PRIu32, cur->str, sval,
cval);
}
break;
case 4: /* INT32 */
{
INT32 sval = freerdp_settings_get_int32(settings, cur->id);
INT32 cval = freerdp_settings_get_int32(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [INT32]: %" PRId32 " -> %" PRId32, cur->str, sval,
cval);
}
break;
case 5: /* UINT64 */
{
UINT64 sval = freerdp_settings_get_uint64(settings, cur->id);
UINT64 cval = freerdp_settings_get_uint64(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [UINT64]: %" PRIu64 " -> %" PRIu64, cur->str, sval,
cval);
}
break;
case 6: /* INT64 */
{
INT64 sval = freerdp_settings_get_int64(settings, cur->id);
INT64 cval = freerdp_settings_get_int64(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [INT64]: %" PRId64 " -> %" PRId64, cur->str, sval,
cval);
}
break;
case 7: /* strings */
{
const char* sval = freerdp_settings_get_string(settings, cur->id);
const char* cval = freerdp_settings_get_string(other, cur->id);
if (sval != cval)
{
if (!sval || !cval || (strcmp(sval, cval) != 0))
WLog_Print(log, level, "%s [STRING]: '%s' -> '%s'", cur->str, sval, cval);
}
}
break;
case 8: /* pointer */
{
const void* sval = freerdp_settings_get_pointer(settings, cur->id);
const void* cval = freerdp_settings_get_pointer(other, cur->id);
if (sval != cval)
WLog_Print(log, level, "%s [POINTER]: '%p' -> '%p'", cur->str, sval, cval);
}
break;
}
}
return TRUE;
}
void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings) void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings)
{ {
size_t x; size_t x;

View File

@ -129,6 +129,94 @@ def write_str(f, entry_dict):
f.write('}\n') f.write('}\n')
f.write('\n') f.write('\n')
f.write('BOOL freerdp_settings_print_diff(wLog* log, DWORD level, const rdpSettings* settings, const rdpSettings* other)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tswitch(cur->type)\n')
f.write('\t\t{\n')
f.write('\t\t\tcase 0: /* bool */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tBOOL sval = freerdp_settings_get_bool(settings, cur->id);\n')
f.write('\t\t\t\tBOOL cval = freerdp_settings_get_bool(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t\tWLog_Print(log, level, "%s [BOOL]: %s -> %s", cur->str, sval ? "TRUE" : "FALSE", cval ? "TRUE" : "FALSE");\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 1: /* UINT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT16 sval = freerdp_settings_get_uint16(settings, cur->id);\n')
f.write('\t\t\t\tUINT16 cval = freerdp_settings_get_uint16(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT16]: %" PRIu16 " -> %" PRIu16, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 2: /* INT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT16 sval = freerdp_settings_get_int16(settings, cur->id);\n')
f.write('\t\t\t\tINT16 cval = freerdp_settings_get_int16(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT16]: %" PRId16 " -> %" PRId16, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 3: /* UINT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT32 sval = freerdp_settings_get_uint32(settings, cur->id);\n')
f.write('\t\t\t\tUINT32 cval = freerdp_settings_get_uint32(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT32]: %" PRIu32 " -> %" PRIu32, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 4: /* INT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT32 sval = freerdp_settings_get_int32(settings, cur->id);\n')
f.write('\t\t\t\tINT32 cval = freerdp_settings_get_int32(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT32]: %" PRId32 " -> %" PRId32, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 5: /* UINT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT64 sval = freerdp_settings_get_uint64(settings, cur->id);\n')
f.write('\t\t\t\tUINT64 cval = freerdp_settings_get_uint64(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT64]: %" PRIu64 " -> %" PRIu64, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 6: /* INT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT64 sval = freerdp_settings_get_int64(settings, cur->id);\n')
f.write('\t\t\t\tINT64 cval = freerdp_settings_get_int64(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT64]: %" PRId64 " -> %" PRId64, cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 7: /* strings */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst char* sval = freerdp_settings_get_string(settings, cur->id);\n')
f.write('\t\t\t\tconst char* cval = freerdp_settings_get_string(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\tif (!sval || !cval || (strcmp(sval, cval) != 0))\n')
f.write('\t\t\t\t\t\tWLog_Print(log, level, "%s [STRING]: \'%s\' -> \'%s\'", cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 8: /* pointer */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst void* sval = freerdp_settings_get_pointer(settings, cur->id);\n')
f.write('\t\t\t\tconst void* cval = freerdp_settings_get_pointer(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [POINTER]: \'%p\' -> \'%p\'", cur->str, sval, cval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t}\n')
f.write('\t}\n')
f.write('\treturn TRUE;\n')
f.write('}\n')
f.write('void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings)\n') f.write('void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings)\n')
f.write('{\n') f.write('{\n')
f.write('\tsize_t x;\n') f.write('\tsize_t x;\n')