[v4 PATCH] odbccp32: Handle ODBC_CONFIG_DRIVER request in SQLConfigDriver/W

Huw Davies huw at codeweavers.com
Wed Apr 26 03:06:50 CDT 2017


On Wed, Apr 26, 2017 at 12:46:49AM +0000, Alistair Leslie-Hughes wrote:
> diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c
> index f28d464..475b74e 100644
> --- a/dlls/odbccp32/odbccp32.c
> +++ b/dlls/odbccp32/odbccp32.c
> @@ -65,6 +65,7 @@ static const WCHAR odbc_error_invalid_param_string[] = {'I','n','v','a','l','i',
>  static const WCHAR odbc_error_invalid_dsn[] = {'I','n','v','a','l','i','d',' ','D','S','N',0};
>  static const WCHAR odbc_error_load_lib_failed[] = {'L','o','a','d',' ','L','i','b','r','a','r','y',' ','F','a','i','l','e','d',0};
>  static const WCHAR odbc_error_request_failed[] = {'R','e','q','u','e','s','t',' ','F','a','i','l','e','d',0};
> +static const WCHAR odbc_error_invalid_keyword[] = {'I','n','v','a','l','i','d',' ','k','e','y','w','o','r','d',' ','v','a','l','u','e',0};
>  
>  /* Push an error onto the error stack, taking care of ranges etc. */
>  static void push_error(int code, LPCWSTR msg)
> @@ -303,6 +304,64 @@ static HMODULE load_config_driver(const WCHAR *driver)
>      return hmod;
>  }
>  
> +static BOOL write_config_value(const WCHAR *driver, const WCHAR *args)
> +{
> +    long ret;
> +    HKEY hkey, hkeydriver;
> +    WCHAR *name = NULL;
> +
> +    if (!args)
> +        return FALSE;
> +
> +    if ((ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, odbcini, &hkey)) == ERROR_SUCCESS)
> +    {
> +        if ((ret = RegOpenKeyW(hkey, driver, &hkeydriver)) == ERROR_SUCCESS)
> +        {
> +            WCHAR *divider, *value;
> +
> +            name = heap_alloc( (strlenW(args) + 1) * sizeof(WCHAR));
> +            if(!name)
> +            {
> +                push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
> +                goto fail;
> +            }
> +            lstrcpyW(name, args);
> +
> +            divider = strchrW(name,'=');
> +            if(!divider)
> +            {
> +                push_error(ODBC_ERROR_INVALID_KEYWORD_VALUE, odbc_error_invalid_keyword);
> +                goto fail;
> +            }
> +
> +            value = divider + 1;
> +            *divider = '\0';
> +
> +            TRACE("Write pair: %s = %s\n", debugstr_w(name), debugstr_w(value));
> +            if(RegSetValueExW(hkeydriver, name, 0, REG_SZ, (BYTE*)value,
> +                               strlenW(value) * sizeof(WCHAR)) != ERROR_SUCCESS)

The length should be (strlenW(value) + 1) * sizeof(WCHAR).  Sorry, I
missed that last time.

While you're at it, decide whether you're going to use a space after
'if' or not, and then be consistent.

Otherwise, this looks good.

Huw.



More information about the wine-devel mailing list