[settings] add freerdp_settings_copy_item
convenience function to copy a value of opaque type from one settings struct to another, cleaning up possible existing data first
This commit is contained in:
parent
13d35c8a98
commit
ecc21a2cfc
@ -1755,6 +1755,20 @@ extern "C"
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_settings_copy(rdpSettings* dst, const rdpSettings* src);
|
||||
|
||||
/** \brief copies one setting identified by \b id from \b src to \b dst
|
||||
*
|
||||
* The function frees up all allocated data in \b dst before copying the data from \b src
|
||||
*
|
||||
* \param dst A pointer for the settings to copy data to. May be NULL (fails copy)
|
||||
* \param src A pointer to the settings to copy. May be NULL (fails copy)
|
||||
* \param id The settings identifier to copy
|
||||
*
|
||||
* \return \b TRUE for success, \b FALSE for failure.
|
||||
*/
|
||||
|
||||
FREERDP_API BOOL freerdp_settings_copy_item(rdpSettings* dst, const rdpSettings* src,
|
||||
size_t id);
|
||||
|
||||
/** \brief Free a settings struct with all data in it
|
||||
*
|
||||
* \param settings A pointer to the settings to free, May be NULL
|
||||
|
@ -997,3 +997,57 @@ const char* freerdp_settings_get_name_for_key(size_t key)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL freerdp_settings_copy_item(rdpSettings* dst, const rdpSettings* src, size_t id)
|
||||
{
|
||||
WINPR_ASSERT(dst);
|
||||
WINPR_ASSERT(src);
|
||||
|
||||
const SSIZE_T key = freerdp_settings_get_type_for_key(id);
|
||||
switch (key)
|
||||
{
|
||||
case FREERDP_SETTINGS_TYPE_BOOL:
|
||||
{
|
||||
const BOOL val = freerdp_settings_get_bool(src, id);
|
||||
return freerdp_settings_set_bool(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_INT16:
|
||||
{
|
||||
const INT16 val = freerdp_settings_get_int16(src, id);
|
||||
return freerdp_settings_set_int16(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_INT32:
|
||||
{
|
||||
const INT32 val = freerdp_settings_get_int32(src, id);
|
||||
return freerdp_settings_set_int32(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_INT64:
|
||||
{
|
||||
const INT64 val = freerdp_settings_get_int64(src, id);
|
||||
return freerdp_settings_set_int64(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_UINT16:
|
||||
{
|
||||
const UINT16 val = freerdp_settings_get_uint16(src, id);
|
||||
return freerdp_settings_set_uint16(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_UINT32:
|
||||
{
|
||||
const UINT32 val = freerdp_settings_get_uint32(src, id);
|
||||
return freerdp_settings_set_uint32(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_UINT64:
|
||||
{
|
||||
const UINT64 val = freerdp_settings_get_uint64(src, id);
|
||||
return freerdp_settings_set_uint64(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_STRING:
|
||||
{
|
||||
const char* val = freerdp_settings_get_string(src, id);
|
||||
return freerdp_settings_set_string(dst, id, val);
|
||||
}
|
||||
case FREERDP_SETTINGS_TYPE_POINTER:
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user