reg: Use wide-char string literals.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aaf503e1de
commit
0c73f95b33
|
@ -48,12 +48,11 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
|
||||||
case REG_BINARY:
|
case REG_BINARY:
|
||||||
{
|
{
|
||||||
WCHAR *ptr;
|
WCHAR *ptr;
|
||||||
static const WCHAR fmt[] = {'%','0','2','X',0};
|
|
||||||
|
|
||||||
buffer = malloc((size_bytes * 2 + 1) * sizeof(WCHAR));
|
buffer = malloc((size_bytes * 2 + 1) * sizeof(WCHAR));
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
for (i = 0; i < size_bytes; i++)
|
for (i = 0; i < size_bytes; i++)
|
||||||
ptr += swprintf(ptr, 3, fmt, src[i]);
|
ptr += swprintf(ptr, 3, L"%02X", src[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_DWORD:
|
case REG_DWORD:
|
||||||
|
@ -61,10 +60,9 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
|
||||||
case REG_DWORD_BIG_ENDIAN:
|
case REG_DWORD_BIG_ENDIAN:
|
||||||
{
|
{
|
||||||
const int zero_x_dword = 10;
|
const int zero_x_dword = 10;
|
||||||
static const WCHAR fmt[] = {'0','x','%','x',0};
|
|
||||||
|
|
||||||
buffer = malloc((zero_x_dword + 1) * sizeof(WCHAR));
|
buffer = malloc((zero_x_dword + 1) * sizeof(WCHAR));
|
||||||
swprintf(buffer, zero_x_dword + 1, fmt, *(DWORD *)src);
|
swprintf(buffer, zero_x_dword + 1, L"0x%x", *(DWORD *)src);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_MULTI_SZ:
|
case REG_MULTI_SZ:
|
||||||
|
@ -102,11 +100,11 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const WCHAR newlineW[] = {'\n',0};
|
static const WCHAR *newlineW = L"\n";
|
||||||
|
|
||||||
static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD data_size)
|
static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD data_size)
|
||||||
{
|
{
|
||||||
static const WCHAR fmt[] = {' ',' ',' ',' ','%','1',0};
|
static const WCHAR *fmt = L" %1";
|
||||||
WCHAR defval[32];
|
WCHAR defval[32];
|
||||||
WCHAR *reg_data;
|
WCHAR *reg_data;
|
||||||
|
|
||||||
|
@ -142,7 +140,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
||||||
DWORD subkey_len;
|
DWORD subkey_len;
|
||||||
DWORD type, path_len, i;
|
DWORD type, path_len, i;
|
||||||
BYTE *data;
|
BYTE *data;
|
||||||
WCHAR fmt[] = {'%','1','\n',0};
|
static const WCHAR *fmt = L"%1\n";
|
||||||
WCHAR *subkey_name, *subkey_path;
|
WCHAR *subkey_name, *subkey_path;
|
||||||
HKEY subkey;
|
HKEY subkey;
|
||||||
|
|
||||||
|
@ -219,13 +217,11 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
||||||
DWORD max_data_bytes = 2048, data_size;
|
DWORD max_data_bytes = 2048, data_size;
|
||||||
DWORD subkey_len;
|
DWORD subkey_len;
|
||||||
DWORD i, type, path_len;
|
DWORD i, type, path_len;
|
||||||
WCHAR fmt[] = {'%','1','\n',0};
|
|
||||||
WCHAR fmt_path[] = {'%','1','\\','%','2','\n',0};
|
|
||||||
WCHAR *value_name, *subkey_name, *subkey_path;
|
WCHAR *value_name, *subkey_name, *subkey_path;
|
||||||
BYTE *data;
|
BYTE *data;
|
||||||
HKEY subkey;
|
HKEY subkey;
|
||||||
|
|
||||||
output_string(fmt, path);
|
output_string(L"%1\n", path);
|
||||||
|
|
||||||
value_name = malloc(max_value_len * sizeof(WCHAR));
|
value_name = malloc(max_value_len * sizeof(WCHAR));
|
||||||
data = malloc(max_data_bytes);
|
data = malloc(max_data_bytes);
|
||||||
|
@ -284,7 +280,7 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
||||||
}
|
}
|
||||||
free(subkey_path);
|
free(subkey_path);
|
||||||
}
|
}
|
||||||
else output_string(fmt_path, path, subkey_name);
|
else output_string(L"%1\\%2\n", path, subkey_name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
|
|
@ -21,17 +21,6 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
||||||
|
|
||||||
static const WCHAR short_hklm[] = {'H','K','L','M',0};
|
|
||||||
static const WCHAR short_hkcu[] = {'H','K','C','U',0};
|
|
||||||
static const WCHAR short_hkcr[] = {'H','K','C','R',0};
|
|
||||||
static const WCHAR short_hku[] = {'H','K','U',0};
|
|
||||||
static const WCHAR short_hkcc[] = {'H','K','C','C',0};
|
|
||||||
static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
|
|
||||||
static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
|
|
||||||
static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
|
|
||||||
static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0};
|
|
||||||
static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
|
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
HKEY key;
|
HKEY key;
|
||||||
|
@ -40,32 +29,23 @@ static const struct
|
||||||
}
|
}
|
||||||
root_rels[] =
|
root_rels[] =
|
||||||
{
|
{
|
||||||
{HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
|
{HKEY_LOCAL_MACHINE, L"HKLM", L"HKEY_LOCAL_MACHINE"},
|
||||||
{HKEY_CURRENT_USER, short_hkcu, long_hkcu},
|
{HKEY_CURRENT_USER, L"HKCU", L"HKEY_CURRENT_USER"},
|
||||||
{HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
|
{HKEY_CLASSES_ROOT, L"HKCR", L"HKEY_CLASSES_ROOT"},
|
||||||
{HKEY_USERS, short_hku, long_hku},
|
{HKEY_USERS, L"HKU", L"HKEY_USERS"},
|
||||||
{HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
|
{HKEY_CURRENT_CONFIG, L"HKCC", L"HKEY_CURRENT_CONFIG"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0};
|
|
||||||
static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0};
|
|
||||||
static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
|
|
||||||
static const WCHAR type_binary[] = {'R','E','G','_','B','I','N','A','R','Y',0};
|
|
||||||
static const WCHAR type_dword[] = {'R','E','G','_','D','W','O','R','D',0};
|
|
||||||
static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
|
|
||||||
static const WCHAR type_dword_be[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
|
|
||||||
static const WCHAR type_multi_sz[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
|
|
||||||
|
|
||||||
const struct reg_type_rels type_rels[] =
|
const struct reg_type_rels type_rels[] =
|
||||||
{
|
{
|
||||||
{REG_NONE, type_none},
|
{REG_NONE, L"REG_NONE"},
|
||||||
{REG_SZ, type_sz},
|
{REG_SZ, L"REG_SZ"},
|
||||||
{REG_EXPAND_SZ, type_expand_sz},
|
{REG_EXPAND_SZ, L"REG_EXPAND_SZ"},
|
||||||
{REG_BINARY, type_binary},
|
{REG_BINARY, L"REG_BINARY"},
|
||||||
{REG_DWORD, type_dword},
|
{REG_DWORD, L"REG_DWORD"},
|
||||||
{REG_DWORD_LITTLE_ENDIAN, type_dword_le},
|
{REG_DWORD_LITTLE_ENDIAN, L"REG_DWORD_LITTLE_ENDIAN"},
|
||||||
{REG_DWORD_BIG_ENDIAN, type_dword_be},
|
{REG_DWORD_BIG_ENDIAN, L"REG_DWORD_BIG_ENDIAN"},
|
||||||
{REG_MULTI_SZ, type_multi_sz},
|
{REG_MULTI_SZ, L"REG_MULTI_SZ"},
|
||||||
};
|
};
|
||||||
|
|
||||||
void output_writeconsole(const WCHAR *str, DWORD wlen)
|
void output_writeconsole(const WCHAR *str, DWORD wlen)
|
||||||
|
@ -216,10 +196,9 @@ static BOOL sane_path(const WCHAR *key)
|
||||||
WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len)
|
WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len)
|
||||||
{
|
{
|
||||||
WCHAR *subkey_path;
|
WCHAR *subkey_path;
|
||||||
static const WCHAR fmt[] = {'%','s','\\','%','s',0};
|
|
||||||
|
|
||||||
subkey_path = malloc((path_len + subkey_len + 2) * sizeof(WCHAR));
|
subkey_path = malloc((path_len + subkey_len + 2) * sizeof(WCHAR));
|
||||||
swprintf(subkey_path, path_len + subkey_len + 2, fmt, path, subkey_name);
|
swprintf(subkey_path, path_len + subkey_len + 2, L"%s\\%s", path, subkey_name);
|
||||||
|
|
||||||
return subkey_path;
|
return subkey_path;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +207,6 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path)
|
||||||
{
|
{
|
||||||
DWORD i, array_size = ARRAY_SIZE(root_rels), len;
|
DWORD i, array_size = ARRAY_SIZE(root_rels), len;
|
||||||
WCHAR *long_key;
|
WCHAR *long_key;
|
||||||
WCHAR fmt[] = {'%','s','\\','%','s',0};
|
|
||||||
|
|
||||||
for (i = 0; i < array_size; i++)
|
for (i = 0; i < array_size; i++)
|
||||||
{
|
{
|
||||||
|
@ -247,7 +225,7 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path)
|
||||||
|
|
||||||
len += lstrlenW(path) + 1; /* add one for the backslash */
|
len += lstrlenW(path) + 1; /* add one for the backslash */
|
||||||
long_key = malloc((len + 1) * sizeof(WCHAR));
|
long_key = malloc((len + 1) * sizeof(WCHAR));
|
||||||
swprintf(long_key, len + 1, fmt, root_rels[i].long_name, path);
|
swprintf(long_key, len + 1, L"%s\\%s", root_rels[i].long_name, path);
|
||||||
return long_key;
|
return long_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,19 +279,13 @@ static enum operations get_operation(const WCHAR *str, int *op_help)
|
||||||
{
|
{
|
||||||
struct op_info { const WCHAR *op; int id; int help_id; };
|
struct op_info { const WCHAR *op; int id; int help_id; };
|
||||||
|
|
||||||
static const WCHAR add[] = {'a','d','d',0};
|
|
||||||
static const WCHAR delete[] = {'d','e','l','e','t','e',0};
|
|
||||||
static const WCHAR export[] = {'e','x','p','o','r','t',0};
|
|
||||||
static const WCHAR import[] = {'i','m','p','o','r','t',0};
|
|
||||||
static const WCHAR query[] = {'q','u','e','r','y',0};
|
|
||||||
|
|
||||||
static const struct op_info op_array[] =
|
static const struct op_info op_array[] =
|
||||||
{
|
{
|
||||||
{ add, REG_ADD, STRING_ADD_USAGE },
|
{ L"add", REG_ADD, STRING_ADD_USAGE },
|
||||||
{ delete, REG_DELETE, STRING_DELETE_USAGE },
|
{ L"delete", REG_DELETE, STRING_DELETE_USAGE },
|
||||||
{ export, REG_EXPORT, STRING_EXPORT_USAGE },
|
{ L"export", REG_EXPORT, STRING_EXPORT_USAGE },
|
||||||
{ import, REG_IMPORT, STRING_IMPORT_USAGE },
|
{ L"import", REG_IMPORT, STRING_IMPORT_USAGE },
|
||||||
{ query, REG_QUERY, STRING_QUERY_USAGE },
|
{ L"query", REG_QUERY, STRING_QUERY_USAGE },
|
||||||
{ NULL, -1, 0 }
|
{ NULL, -1, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue