From 3cfeed64b1af12c54efc5342d4bcbaf61b4ca185 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 23 Dec 2019 00:58:26 +0100 Subject: [PATCH] [REG] Sync with Wine Staging 4.18. CORE-16441 --- base/applications/cmdutils/reg/export.c | 20 +- base/applications/cmdutils/reg/import.c | 42 ++-- base/applications/cmdutils/reg/lang/bg-BG.rc | 2 - base/applications/cmdutils/reg/lang/cs-CZ.rc | 2 - base/applications/cmdutils/reg/lang/da-DK.rc | 2 - base/applications/cmdutils/reg/lang/de-DE.rc | 2 - base/applications/cmdutils/reg/lang/en-US.rc | 2 - base/applications/cmdutils/reg/lang/es-ES.rc | 2 - base/applications/cmdutils/reg/lang/fr-FR.rc | 2 - base/applications/cmdutils/reg/lang/it-IT.rc | 2 - base/applications/cmdutils/reg/lang/ja-JP.rc | 2 - base/applications/cmdutils/reg/lang/ko-KR.rc | 2 - base/applications/cmdutils/reg/lang/lt-LT.rc | 2 - base/applications/cmdutils/reg/lang/nl-NL.rc | 2 - base/applications/cmdutils/reg/lang/no-NO.rc | 2 - base/applications/cmdutils/reg/lang/pl-PL.rc | 2 - base/applications/cmdutils/reg/lang/pt-PT.rc | 2 - base/applications/cmdutils/reg/lang/ro-RO.rc | 2 - base/applications/cmdutils/reg/lang/ru-RU.rc | 2 - base/applications/cmdutils/reg/lang/sl-SI.rc | 2 - base/applications/cmdutils/reg/lang/sq-AL.rc | 2 - base/applications/cmdutils/reg/lang/sv-SE.rc | 2 - base/applications/cmdutils/reg/lang/tr-TR.rc | 2 - base/applications/cmdutils/reg/lang/uk-UA.rc | 2 - base/applications/cmdutils/reg/lang/zh-CN.rc | 2 - base/applications/cmdutils/reg/lang/zh-TW.rc | 2 - base/applications/cmdutils/reg/reg.c | 214 +++---------------- base/applications/cmdutils/reg/resource.h | 2 - media/doc/README.WINE | 2 +- 29 files changed, 55 insertions(+), 273 deletions(-) diff --git a/base/applications/cmdutils/reg/export.c b/base/applications/cmdutils/reg/export.c index 8b08da12999..b5796d5fef3 100644 --- a/base/applications/cmdutils/reg/export.c +++ b/base/applications/cmdutils/reg/export.c @@ -17,9 +17,9 @@ */ #include +#include #include -#include #include #include "reg.h" @@ -92,7 +92,7 @@ static size_t export_value_name(HANDLE hFile, WCHAR *name, size_t len) { WCHAR *str = escape_string(name, len, &line_len); WCHAR *buf = heap_xalloc((line_len + 4) * sizeof(WCHAR)); - line_len = sprintfW(buf, quoted_fmt, str); + line_len = swprintf(buf, quoted_fmt, str); write_file(hFile, buf); heap_free(buf); heap_free(str); @@ -116,7 +116,7 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size) len = size / sizeof(WCHAR) - 1; str = escape_string(data, len, &line_len); *buf = heap_xalloc((line_len + 3) * sizeof(WCHAR)); - sprintfW(*buf, fmt, str); + swprintf(*buf, fmt, str); heap_free(str); } @@ -125,7 +125,7 @@ static void export_dword_data(WCHAR **buf, DWORD *data) static const WCHAR fmt[] = {'d','w','o','r','d',':','%','0','8','x',0}; *buf = heap_xalloc(15 * sizeof(WCHAR)); - sprintfW(*buf, fmt, *data); + swprintf(*buf, fmt, *data); } static size_t export_hex_data_type(HANDLE hFile, DWORD type) @@ -142,7 +142,7 @@ static size_t export_hex_data_type(HANDLE hFile, DWORD type) else { WCHAR *buf = heap_xalloc(15 * sizeof(WCHAR)); - line_len = sprintfW(buf, hexp_fmt, type); + line_len = swprintf(buf, hexp_fmt, type); write_file(hFile, buf); heap_free(buf); } @@ -168,7 +168,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type, for (i = 0, pos = 0; i < size; i++) { - pos += sprintfW(*buf + pos, fmt, ((BYTE *)data)[i]); + pos += swprintf(*buf + pos, fmt, ((BYTE *)data)[i]); if (i == num_commas) break; (*buf)[pos++] = ','; (*buf)[pos] = 0; @@ -233,7 +233,7 @@ static void export_key_name(HANDLE hFile, WCHAR *name) WCHAR *buf; buf = heap_xalloc((lstrlenW(name) + 7) * sizeof(WCHAR)); - sprintfW(buf, fmt, name); + swprintf(buf, fmt, name); write_file(hFile, buf); heap_free(buf); } @@ -316,7 +316,7 @@ static void export_file_header(HANDLE hFile) { static const WCHAR header[] = { 0xfeff,'W','i','n','d','o','w','s',' ', 'R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ', - 'V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n'}; + 'V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n',0}; write_file(hFile, header); } @@ -361,7 +361,7 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file) static BOOL is_overwrite_switch(const WCHAR *s) { - if (strlenW(s) > 2) + if (lstrlenW(s) > 2) return FALSE; if ((s[0] == '/' || s[0] == '-') && (s[1] == 'y' || s[1] == 'Y')) @@ -405,6 +405,6 @@ int reg_export(int argc, WCHAR *argv[]) error: output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, struprW(argv[1])); + output_message(STRING_FUNC_HELP, _wcsupr(argv[1])); return 1; } diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index 779ea2863b0..f7f87939e23 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -162,7 +161,7 @@ static BOOL convert_hex_to_dword(WCHAR *str, DWORD *dw) if (!*str) goto error; p = str; - while (isxdigitW(*p)) + while (iswxdigit(*p)) { count++; p++; @@ -174,7 +173,7 @@ static BOOL convert_hex_to_dword(WCHAR *str, DWORD *dw) if (*p && *p != ';') goto error; *end = 0; - *dw = strtoulW(str, &end, 16); + *dw = wcstoul(str, &end, 16); return TRUE; error: @@ -207,7 +206,7 @@ static BOOL convert_hex_csv_to_hex(struct parser *parser, WCHAR **str) WCHAR *end; unsigned long wc; - wc = strtoulW(s, &end, 16); + wc = wcstoul(s, &end, 16); if (wc > 0xff) return FALSE; if (s == end && wc == 0) @@ -269,7 +268,7 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line) for (ptr = data_types; ptr->tag; ptr++) { - if (strncmpW(ptr->tag, *line, ptr->len)) + if (wcsncmp(ptr->tag, *line, ptr->len)) continue; parser->parse_type = ptr->parse_type; @@ -281,7 +280,7 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line) WCHAR *end; DWORD val; - if (!**line || tolowerW((*line)[1]) == 'x') + if (!**line || towlower((*line)[1]) == 'x') return FALSE; /* "hex(xx):" is special */ @@ -354,7 +353,7 @@ static HKEY parse_key_name(WCHAR *key_name, WCHAR **key_path) { if (!key_name) return 0; - *key_path = strchrW(key_name, '\\'); + *key_path = wcschr(key_name, '\\'); if (*key_path) (*key_path)++; return path_get_rootkey(key_name); @@ -458,13 +457,13 @@ static enum reg_versions parse_file_header(const WCHAR *s) while (*s == ' ' || *s == '\t') s++; - if (!strcmpW(s, header_31)) + if (!lstrcmpW(s, header_31)) return REG_VERSION_31; - if (!strcmpW(s, header_40)) + if (!lstrcmpW(s, header_40)) return REG_VERSION_40; - if (!strcmpW(s, header_50)) + if (!lstrcmpW(s, header_50)) return REG_VERSION_50; /* The Windows version accepts registry file headers beginning with "REGEDIT" and ending @@ -472,7 +471,7 @@ static enum reg_versions parse_file_header(const WCHAR *s) * "REGEDIT 4", "REGEDIT9" and "REGEDIT4FOO" are all treated as valid file headers. * In all such cases, however, the contents of the registry file are not imported. */ - if (!strncmpW(s, header_31, 7)) /* "REGEDIT" without NUL */ + if (!wcsncmp(s, header_31, 7)) /* "REGEDIT" without NUL */ return REG_VERSION_FUZZY; return REG_VERSION_INVALID; @@ -524,11 +523,11 @@ static WCHAR *parse_win31_line_state(struct parser *parser, WCHAR *pos) if (!(line = get_line(parser->file))) return NULL; - if (strncmpW(line, hkcr, ARRAY_SIZE(hkcr))) + if (wcsncmp(line, hkcr, ARRAY_SIZE(hkcr))) return line; /* get key name */ - while (line[key_end] && !isspaceW(line[key_end])) key_end++; + while (line[key_end] && !iswspace(line[key_end])) key_end++; value = line + key_end; while (*value == ' ' || *value == '\t') value++; @@ -590,7 +589,7 @@ static WCHAR *key_name_state(struct parser *parser, WCHAR *pos) { WCHAR *p = pos, *key_end; - if (*p == ' ' || *p == '\t' || !(key_end = strrchrW(p, ']'))) + if (*p == ' ' || *p == '\t' || !(key_end = wcsrchr(p, ']'))) goto done; *key_end = 0; @@ -645,11 +644,8 @@ static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos) { WCHAR *val_name = pos, *p; - if (parser->value_name) - { - heap_free(parser->value_name); - parser->value_name = NULL; - } + heap_free(parser->value_name); + parser->value_name = NULL; if (!unescape_string(val_name, &p)) goto invalid; @@ -678,7 +674,7 @@ static WCHAR *data_start_state(struct parser *parser, WCHAR *pos) while (*p == ' ' || *p == '\t') p++; /* trim trailing whitespace */ - len = strlenW(p); + len = lstrlenW(p); while (len > 0 && (p[len - 1] == ' ' || p[len - 1] == '\t')) len--; p[len] = 0; @@ -843,7 +839,7 @@ static WCHAR *hex_multiline_state(struct parser *parser, WCHAR *pos) while (*line == ' ' || *line == '\t') line++; if (!*line || *line == ';') return line; - if (!isxdigitW(*line)) goto invalid; + if (!iswxdigit(*line)) goto invalid; set_state(parser, HEX_DATA); return line; @@ -959,11 +955,11 @@ static WCHAR *get_lineW(FILE *fp) while (next) { static const WCHAR line_endings[] = {'\r','\n',0}; - WCHAR *p = strpbrkW(line, line_endings); + WCHAR *p = wcspbrk(line, line_endings); if (!p) { size_t len, count; - len = strlenW(next); + len = lstrlenW(next); memmove(buf, next, (len + 1) * sizeof(WCHAR)); if (size - len < 3) { diff --git a/base/applications/cmdutils/reg/lang/bg-BG.rc b/base/applications/cmdutils/reg/lang/bg-BG.rc index 0ea098c3a44..7f5bd99572d 100644 --- a/base/applications/cmdutils/reg/lang/bg-BG.rc +++ b/base/applications/cmdutils/reg/lang/bg-BG.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/cs-CZ.rc b/base/applications/cmdutils/reg/lang/cs-CZ.rc index e4413cbce02..c50105f449c 100644 --- a/base/applications/cmdutils/reg/lang/cs-CZ.rc +++ b/base/applications/cmdutils/reg/lang/cs-CZ.rc @@ -45,6 +45,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/da-DK.rc b/base/applications/cmdutils/reg/lang/da-DK.rc index a7bf9e9361a..bb882d6eefd 100644 --- a/base/applications/cmdutils/reg/lang/da-DK.rc +++ b/base/applications/cmdutils/reg/lang/da-DK.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/de-DE.rc b/base/applications/cmdutils/reg/lang/de-DE.rc index dba7ed54791..adeb062f8d1 100644 --- a/base/applications/cmdutils/reg/lang/de-DE.rc +++ b/base/applications/cmdutils/reg/lang/de-DE.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/en-US.rc b/base/applications/cmdutils/reg/lang/en-US.rc index 65c37f1a803..b2cf9875cc6 100644 --- a/base/applications/cmdutils/reg/lang/en-US.rc +++ b/base/applications/cmdutils/reg/lang/en-US.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/es-ES.rc b/base/applications/cmdutils/reg/lang/es-ES.rc index 5e6d9ed4cd5..a087d8cd4e5 100644 --- a/base/applications/cmdutils/reg/lang/es-ES.rc +++ b/base/applications/cmdutils/reg/lang/es-ES.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/fr-FR.rc b/base/applications/cmdutils/reg/lang/fr-FR.rc index 0419d350e80..e288ad9928f 100644 --- a/base/applications/cmdutils/reg/lang/fr-FR.rc +++ b/base/applications/cmdutils/reg/lang/fr-FR.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/it-IT.rc b/base/applications/cmdutils/reg/lang/it-IT.rc index 84417873ed1..082a1875e6f 100644 --- a/base/applications/cmdutils/reg/lang/it-IT.rc +++ b/base/applications/cmdutils/reg/lang/it-IT.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/ja-JP.rc b/base/applications/cmdutils/reg/lang/ja-JP.rc index cbaeb46f7fd..6c3b6b7abe4 100644 --- a/base/applications/cmdutils/reg/lang/ja-JP.rc +++ b/base/applications/cmdutils/reg/lang/ja-JP.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/ko-KR.rc b/base/applications/cmdutils/reg/lang/ko-KR.rc index 1ba6c381f31..513d0542408 100644 --- a/base/applications/cmdutils/reg/lang/ko-KR.rc +++ b/base/applications/cmdutils/reg/lang/ko-KR.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/lt-LT.rc b/base/applications/cmdutils/reg/lang/lt-LT.rc index 48e96d23c97..556a78dde1f 100644 --- a/base/applications/cmdutils/reg/lang/lt-LT.rc +++ b/base/applications/cmdutils/reg/lang/lt-LT.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/nl-NL.rc b/base/applications/cmdutils/reg/lang/nl-NL.rc index 1cf44949866..f4326d684b4 100644 --- a/base/applications/cmdutils/reg/lang/nl-NL.rc +++ b/base/applications/cmdutils/reg/lang/nl-NL.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/no-NO.rc b/base/applications/cmdutils/reg/lang/no-NO.rc index 2046fad5278..ed7e9499154 100644 --- a/base/applications/cmdutils/reg/lang/no-NO.rc +++ b/base/applications/cmdutils/reg/lang/no-NO.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/pl-PL.rc b/base/applications/cmdutils/reg/lang/pl-PL.rc index 3c87ef40021..aca63678954 100644 --- a/base/applications/cmdutils/reg/lang/pl-PL.rc +++ b/base/applications/cmdutils/reg/lang/pl-PL.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT nazwa_klucza plik.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Nieprawidłowy klucz systemowy [%1]\n" STRING_OVERWRITE_FILE, "Plik '%1' już istnieje. Czy chcesz go zastąpić?" - STRING_SAVE_USAGE, "REG SAVE nazwa_klucza nazwa_pliku [/y]" - STRING_RESTORE_USAGE, "REG RESTORE nazwa_klucza nazwa_pliku" } diff --git a/base/applications/cmdutils/reg/lang/pt-PT.rc b/base/applications/cmdutils/reg/lang/pt-PT.rc index 58e8752324e..bbb3d21b2f8 100644 --- a/base/applications/cmdutils/reg/lang/pt-PT.rc +++ b/base/applications/cmdutils/reg/lang/pt-PT.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/ro-RO.rc b/base/applications/cmdutils/reg/lang/ro-RO.rc index 3ee1f903895..d9e409fb1f1 100644 --- a/base/applications/cmdutils/reg/lang/ro-RO.rc +++ b/base/applications/cmdutils/reg/lang/ro-RO.rc @@ -46,6 +46,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT nume_cheie fișier.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Cheia de sistem [%1] nu este una validă.\n" STRING_OVERWRITE_FILE, "Fișierul «%1» deja există. Doriți suprascrierea lui?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/ru-RU.rc b/base/applications/cmdutils/reg/lang/ru-RU.rc index 757926b9b68..6b797135607 100644 --- a/base/applications/cmdutils/reg/lang/ru-RU.rc +++ b/base/applications/cmdutils/reg/lang/ru-RU.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/sl-SI.rc b/base/applications/cmdutils/reg/lang/sl-SI.rc index d0f4b37e82c..7b8192e026a 100644 --- a/base/applications/cmdutils/reg/lang/sl-SI.rc +++ b/base/applications/cmdutils/reg/lang/sl-SI.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/sq-AL.rc b/base/applications/cmdutils/reg/lang/sq-AL.rc index a94677b8c6c..0e11b22f121 100644 --- a/base/applications/cmdutils/reg/lang/sq-AL.rc +++ b/base/applications/cmdutils/reg/lang/sq-AL.rc @@ -44,6 +44,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/sv-SE.rc b/base/applications/cmdutils/reg/lang/sv-SE.rc index c015bd9d6f9..fe61d5c62e0 100644 --- a/base/applications/cmdutils/reg/lang/sv-SE.rc +++ b/base/applications/cmdutils/reg/lang/sv-SE.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/tr-TR.rc b/base/applications/cmdutils/reg/lang/tr-TR.rc index 47abfc54bf8..6fdcb253830 100644 --- a/base/applications/cmdutils/reg/lang/tr-TR.rc +++ b/base/applications/cmdutils/reg/lang/tr-TR.rc @@ -42,6 +42,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/uk-UA.rc b/base/applications/cmdutils/reg/lang/uk-UA.rc index f2fff4f5e67..0dae3894dce 100644 --- a/base/applications/cmdutils/reg/lang/uk-UA.rc +++ b/base/applications/cmdutils/reg/lang/uk-UA.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/zh-CN.rc b/base/applications/cmdutils/reg/lang/zh-CN.rc index 08f92516977..aeaea14a55b 100644 --- a/base/applications/cmdutils/reg/lang/zh-CN.rc +++ b/base/applications/cmdutils/reg/lang/zh-CN.rc @@ -40,6 +40,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: 无效的系统键 [%1]\n" STRING_OVERWRITE_FILE, "文件 '%1' 已经存在。您是否要覆盖它?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/lang/zh-TW.rc b/base/applications/cmdutils/reg/lang/zh-TW.rc index 7771b9ea401..d55fa7e6093 100644 --- a/base/applications/cmdutils/reg/lang/zh-TW.rc +++ b/base/applications/cmdutils/reg/lang/zh-TW.rc @@ -42,6 +42,4 @@ STRINGTABLE STRING_EXPORT_USAGE, "REG EXPORT key_name file.reg [/y]\n" STRING_INVALID_SYSTEM_KEY, "reg: Invalid system key [%1]\n" STRING_OVERWRITE_FILE, "The file '%1' already exists. Do you want to overwrite it?" - STRING_SAVE_USAGE, "REG SAVE key_name file_name [/y]" - STRING_RESTORE_USAGE, "REG RESTORE key_name file_name" } diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 5e65aee269b..21a08615531 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include #include "reg.h" @@ -144,23 +144,6 @@ static void output_formatstring(const WCHAR *fmt, __ms_va_list va_args) LocalFree(str); } -static void output_error(LSTATUS status) -{ - WCHAR* str; - DWORD len; - - SetLastError(NO_ERROR); - len = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, status, 0, (WCHAR*)&str, 0, NULL); - if (len == 0 && GetLastError() != NO_ERROR) - { - WINE_FIXME("Could not format error code: le=%u, error=%u", GetLastError(), status); - return; - } - - output_writeconsole(str, len); - LocalFree(str); -} - void WINAPIV output_message(unsigned int id, ...) { WCHAR fmt[1024]; @@ -208,7 +191,7 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info) output_message(msgid, str); output_message(STRING_YESNO); ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), answer, ARRAY_SIZE(answer), &count, NULL); - answer[0] = toupperW(answer[0]); + answer[0] = towupper(answer[0]); if (answer[0] == Ybuffer[0]) return TRUE; if (answer[0] == Nbuffer[0]) @@ -218,9 +201,9 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info) static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name) { - DWORD length = strlenW(rootkey_name); + DWORD length = lstrlenW(rootkey_name); - return (!strncmpiW(input_path, rootkey_name, length) && + return (!_wcsnicmp(input_path, rootkey_name, length) && (input_path[length] == 0 || input_path[length] == '\\')); } @@ -247,7 +230,7 @@ static DWORD wchar_get_type(const WCHAR *type_name) for (i = 0; i < ARRAY_SIZE(type_rels); i++) { - if (!strcmpiW(type_rels[i].name, type_name)) + if (!wcsicmp(type_rels[i].name, type_name)) return type_rels[i].type; } @@ -292,7 +275,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW { LPWSTR rest; unsigned long val; - val = wcstoul(data, &rest, (tolowerW(data[1]) == 'x') ? 16 : 10); + val = wcstoul(data, &rest, (towlower(data[1]) == 'x') ? 16 : 10); if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) { output_message(STRING_MISSING_INTEGER); break; @@ -333,7 +316,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW } case REG_MULTI_SZ: { - int i, destindex, len = strlenW(data); + int i, destindex, len = lstrlenW(data); WCHAR *buffer = heap_xalloc((len + 2) * sizeof(WCHAR)); for (i = 0, destindex = 0; i < len; i++, destindex++) @@ -370,7 +353,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW static BOOL sane_path(const WCHAR *key) { - unsigned int i = strlenW(key); + unsigned int i = lstrlenW(key); if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\')) { @@ -545,7 +528,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) case REG_SZ: case REG_EXPAND_SZ: buffer = heap_xalloc(size_bytes); - strcpyW(buffer, (WCHAR *)src); + lstrcpyW(buffer, (WCHAR *)src); break; case REG_NONE: case REG_BINARY: @@ -556,7 +539,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) buffer = heap_xalloc((size_bytes * 2 + 1) * sizeof(WCHAR)); ptr = buffer; for (i = 0; i < size_bytes; i++) - ptr += sprintfW(ptr, fmt, src[i]); + ptr += swprintf(ptr, fmt, src[i]); break; } case REG_DWORD: @@ -567,7 +550,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) static const WCHAR fmt[] = {'0','x','%','x',0}; buffer = heap_xalloc((zero_x_dword + 1) * sizeof(WCHAR)); - sprintfW(buffer, fmt, *(DWORD *)src); + swprintf(buffer, fmt, *(DWORD *)src); break; } case REG_MULTI_SZ: @@ -652,7 +635,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD static const WCHAR fmt[] = {'%','s','\\','%','s',0}; subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR)); - sprintfW(subkey_path, fmt, path, subkey_name); + swprintf(subkey_path, fmt, path, subkey_name); return subkey_path; } @@ -711,7 +694,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse) subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); - path_len = strlenW(path); + path_len = lstrlenW(path); i = 0; for (;;) @@ -789,7 +772,7 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse) subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); - path_len = strlenW(path); + path_len = lstrlenW(path); i = 0; for (;;) @@ -862,18 +845,18 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path) break; } - len = strlenW(root_rels[i].long_name); + len = lstrlenW(root_rels[i].long_name); if (!path) { long_key = heap_xalloc((len + 1) * sizeof(WCHAR)); - strcpyW(long_key, root_rels[i].long_name); + lstrcpyW(long_key, root_rels[i].long_name); return long_key; } - len += strlenW(path) + 1; /* add one for the backslash */ + len += lstrlenW(path) + 1; /* add one for the backslash */ long_key = heap_xalloc((len + 1) * sizeof(WCHAR)); - sprintfW(long_key, fmt, root_rels[i].long_name, path); + swprintf(long_key, fmt, root_rels[i].long_name, path); return long_key; } @@ -882,7 +865,7 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long if (!sane_path(key)) return FALSE; - *path = strchrW(key, '\\'); + *path = wcschr(key, '\\'); if (*path) (*path)++; *root = path_get_rootkey(key); @@ -900,150 +883,15 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long static BOOL is_switch(const WCHAR *s, const WCHAR c) { - if (strlenW(s) > 2) + if (lstrlenW(s) > 2) return FALSE; - if ((s[0] == '/' || s[0] == '-') && (s[1] == c || s[1] == toupperW(c))) + if ((s[0] == '/' || s[0] == '-') && (s[1] == c || s[1] == towupper(c))) return TRUE; return FALSE; } -static BOOL set_privilege(LPCWSTR privilegeName, BOOL enabled) -{ - HANDLE hToken = INVALID_HANDLE_VALUE; - TOKEN_PRIVILEGES tp; - DWORD error = ERROR_SUCCESS; - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) - { - tp.PrivilegeCount = 1; - tp.Privileges[0].Attributes = (enabled ? SE_PRIVILEGE_ENABLED : 0); - - if (LookupPrivilegeValueW(NULL, privilegeName, &tp.Privileges[0].Luid)) - { - if (AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL)) - { - if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) - { - error = ERROR_NOT_ALL_ASSIGNED; - goto fail; - } - } - else - { - error = GetLastError(); - goto fail; - } - } - else - { - error = GetLastError(); - goto fail; - } - } - else - { - error = GetLastError(); - goto fail; - } - - CloseHandle(hToken); - return TRUE; - -fail: - // Don't allow a success error to be printed, as that would confuse the user. - // "Access denied" seems like a reasonable default. - if (error == ERROR_SUCCESS) error = ERROR_ACCESS_DENIED; - if (hToken != INVALID_HANDLE_VALUE) CloseHandle(hToken); - - output_error(error); - return FALSE; -} - -static int reg_save(int argc, WCHAR* argv[]) { - HKEY root, hkey; - LSTATUS status; - WCHAR* path, *long_key; - - if (argc < 4 || argc > 5) goto error; - - if (!parse_registry_key(argv[2], &root, &path, &long_key)) - return 1; - - if (GetFileAttributes(argv[3]) != INVALID_FILE_ATTRIBUTES) - { - if (argc == 5 && !strcmpiW(argv[4], L"/y")) - { - DeleteFile(argv[3]); - } - else - { - if (ask_confirm(STRING_OVERWRITE_FILE, argv[3])) - DeleteFile(argv[3]); - } - } - - if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey)) - { - output_message(STRING_INVALID_KEY); - return 1; - } - - if (!set_privilege(SE_BACKUP_NAME, TRUE)) return 1; - - status = RegSaveKeyExW(hkey, argv[3], NULL, REG_LATEST_FORMAT); - RegCloseKey(hkey); - - if (status != ERROR_SUCCESS) { - output_error(status); - return 1; - } - - return 0; - -error: - output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, struprW(argv[1])); - return 1; -} - -static int reg_restore(int argc, WCHAR* argv[]) -{ - HKEY root, hkey; - LSTATUS status; - WCHAR* path, * long_key; - - if (argc != 4) goto error; - - if (!parse_registry_key(argv[2], &root, &path, &long_key)) - return 1; - - if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey)) - { - output_message(STRING_INVALID_KEY); - return 1; - } - - if (!set_privilege(SE_BACKUP_NAME, TRUE)) return 1; - if (!set_privilege(SE_RESTORE_NAME, TRUE)) return 1; - - status = RegRestoreKeyW(hkey, argv[3], 0); - RegCloseKey(hkey); - - if (status != ERROR_SUCCESS) { - output_error(status); - return 1; - } - - return 0; - -error: - output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, struprW(argv[1])); - return 1; -} - static BOOL is_help_switch(const WCHAR *s) { if (is_switch(s, '?') || is_switch(s, 'h')) @@ -1058,8 +906,6 @@ enum operations { REG_IMPORT, REG_EXPORT, REG_QUERY, - REG_SAVE, - REG_RESTORE, REG_INVALID }; @@ -1072,8 +918,6 @@ static enum operations get_operation(const WCHAR *str, int *op_help) static const WCHAR import[] = {'i','m','p','o','r','t',0}; static const WCHAR export[] = {'e','x','p','o','r','t',0}; static const WCHAR query[] = {'q','u','e','r','y',0}; - static const WCHAR save[] = L"save"; - static const WCHAR restore[] = L"restore"; static const struct op_info op_array[] = { @@ -1082,8 +926,6 @@ static enum operations get_operation(const WCHAR *str, int *op_help) { import, REG_IMPORT, STRING_IMPORT_USAGE }, { export, REG_EXPORT, STRING_EXPORT_USAGE }, { query, REG_QUERY, STRING_QUERY_USAGE }, - { save, REG_SAVE, STRING_SAVE_USAGE }, - { restore, REG_RESTORE, STRING_RESTORE_USAGE }, { NULL, -1, 0 } }; @@ -1101,7 +943,7 @@ static enum operations get_operation(const WCHAR *str, int *op_help) return REG_INVALID; } -int wmain(int argc, WCHAR *argvW[]) +int __cdecl wmain(int argc, WCHAR *argvW[]) { int i, op, op_help, ret; BOOL show_op_help = FALSE; @@ -1139,7 +981,7 @@ int wmain(int argc, WCHAR *argvW[]) if (argc == 2 || ((show_op_help || op == REG_IMPORT) && argc > 3)) { output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, struprW(argvW[1])); + output_message(STRING_FUNC_HELP, _wcsupr(argvW[1])); return 1; } else if (show_op_help) @@ -1154,12 +996,6 @@ int wmain(int argc, WCHAR *argvW[]) if (op == REG_EXPORT) return reg_export(argc, argvW); - if (op == REG_SAVE) - return reg_save(argc, argvW); - - if (op == REG_RESTORE) - return reg_restore(argc, argvW); - if (!parse_registry_key(argvW[2], &root, &path, &key_name)) return 1; @@ -1185,7 +1021,7 @@ int wmain(int argc, WCHAR *argvW[]) return 1; } - switch(tolowerW(argvW[i][1])) + switch(towlower(argvW[i][1])) { case 'v': if (value_name || !(value_name = argvW[++i])) @@ -1216,7 +1052,7 @@ int wmain(int argc, WCHAR *argvW[]) } ptr = argvW[++i]; - if (!ptr || strlenW(ptr) != 1) + if (!ptr || lstrlenW(ptr) != 1) { output_message(STRING_INVALID_CMDLINE); return 1; diff --git a/base/applications/cmdutils/reg/resource.h b/base/applications/cmdutils/reg/resource.h index 06848ca4eca..3658adc1556 100644 --- a/base/applications/cmdutils/reg/resource.h +++ b/base/applications/cmdutils/reg/resource.h @@ -61,5 +61,3 @@ #define STRING_EXPORT_USAGE 136 #define STRING_INVALID_SYSTEM_KEY 137 #define STRING_OVERWRITE_FILE 138 -#define STRING_SAVE_USAGE 139 -#define STRING_RESTORE_USAGE 140 diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 82a641bd24d..acaca77a32d 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -229,7 +229,7 @@ win32ss/printing/monitors/localmon/ui/ # Synced to WineStaging-4.18 (known ther ReactOS shares the following programs with Winehq. base/applications/cmdutils/cscript # Synced to WineStaging-4.18 -base/applications/cmdutils/reg # Synced to WineStaging-3.17 +base/applications/cmdutils/reg # Synced to WineStaging-4.18 base/applications/cmdutils/schtasks # Synced to WineStaging-3.3 base/applications/cmdutils/taskkill # Synced to WineStaging-3.17 base/applications/cmdutils/wmic # Synced to WineStaging-4.0