int configuration_reader_get_wchar_string()

in src/configuration_reader.c [557:609]


int configuration_reader_get_wchar_string(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, wchar_t** value)
{
    int result;

    if (
        /*Codes_SRS_CONFIGURATION_READER_42_033: [ If activation_context is NULL then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
        activation_context == NULL ||
        /*Codes_SRS_CONFIGURATION_READER_42_034: [ If config_package_name is NULL or empty then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
        (config_package_name == NULL || config_package_name[0] == L'\0') ||
        /*Codes_SRS_CONFIGURATION_READER_42_035: [ If section_name is NULL or empty then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
        (section_name == NULL || section_name[0] == L'\0') ||
        /*Codes_SRS_CONFIGURATION_READER_42_036: [ If parameter_name is NULL or empty then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
        (parameter_name == NULL || parameter_name[0] == L'\0') ||
        /*Codes_SRS_CONFIGURATION_READER_42_037: [ If value is NULL then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
        (value == NULL)
        )
    {
        LogError("Invalid args: IFabricCodePackageActivationContext* activation_context = %p, const wchar_t* config_package_name = %ls, const wchar_t* section_name = %ls, const wchar_t* parameter_name = %ls, wchar_t** value = %p",
            activation_context, MU_WP_OR_NULL(config_package_name), MU_WP_OR_NULL(section_name), MU_WP_OR_NULL(parameter_name), value);
        result = MU_FAILURE;
    }
    else
    {
        IFabricConfigurationPackage* fabric_configuration_package;
        const wchar_t* wchar_value;
        if (get_string_value_from_package(activation_context, config_package_name, section_name, parameter_name, &fabric_configuration_package, &wchar_value) != 0)
        {
            // already logged error
            result = MU_FAILURE;
        }
        else
        {
            /*Codes_SRS_CONFIGURATION_READER_42_040: [ configuration_reader_get_wchar_string shall copy the string and store it in value. ]*/
            *value = sprintf_wchar(L"%s", wchar_value);

            if (*value == NULL)
            {
                /*Codes_SRS_CONFIGURATION_READER_42_041: [ If there are any other failures then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
                LogError("Failed to copy string %ls (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
                    wchar_value, config_package_name, section_name, parameter_name);
                result = MU_FAILURE;
            }
            else
            {
                /*Codes_SRS_CONFIGURATION_READER_42_042: [ configuration_reader_get_wchar_string shall succeed and return 0. ]*/
                result = 0;
            }
            (void)fabric_configuration_package->lpVtbl->Release(fabric_configuration_package);
        }
    }

    return result;
}