On Wed, 2011-08-17 at 08:19 -0700, Dan Kegel wrote: > On Wed, Aug 17, 2011 at 8:17 AM, Dan Kegel <[email protected]> wrote: > > Hi Nowres, > > did you run the regedit tests, > > cd programs/regedit/tests > > make test > > after that change? Here it fails with > > regedit.c:384: Test failed: regedit not available, skipping regedit tests > > ( log at http://buildbot.kegel.com/builders/runtests/builds/2 ) > > You might need to fully implement the /S switch for regedit and use it > > from the tests before you can add the confirmation dialog to regedit. > > Ah, of course, the tests already use /S, since they pass on windows. > So you just need to make your dialog not show up when /S is given.
I updated the patch. can you please check it?
>From 938512a27114da8698bdc2d4ca9afd55bd034113 Mon Sep 17 00:00:00 2001 From: Nowres Rafid <[email protected]> Date: Thu, 18 Aug 2011 00:56:37 +0000 Subject: regedit: asking for confirmation before importing a file --- programs/regedit/regedit.c | 51 ++++++++++++++++++++++++++++++++++++------ programs/regedit/regedit.rc | 7 ++++++ programs/regedit/resource.h | 3 ++ 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/programs/regedit/regedit.c b/programs/regedit/regedit.c index cc0fc3a..7cd167b 100644 --- a/programs/regedit/regedit.c +++ b/programs/regedit/regedit.c @@ -18,10 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <ctype.h> -#include <stdio.h> #include <windows.h> +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> + +#include "resource.h" #include "regproc.h" +#include "wine/unicode.h" static const char *usage = "Usage:\n" @@ -40,7 +44,6 @@ static const char *usage = " file. Exports the whole registry if no key is specified.\n" " /D - deletes specified registry key\n" " /S - silent execution, can be used with any other switch.\n" - " Default. The only existing mode, exists for compatibility with Windows regedit.\n" " /V - advanced mode, can be used with any other switch.\n" " Ignored, exists for compatibility with Windows regedit.\n" " /L - location of system.dat file. Can be used with any other switch.\n" @@ -122,7 +125,7 @@ static void get_file_name(CHAR **command_line, CHAR *file_name) (*command_line) += pos; } -static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) +static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s, BOOL silent) { switch (action) { case ACTION_ADD: { @@ -142,6 +145,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) if (strcmp(filename, "-") == 0) { reg_file = stdin; + import_registry_file(reg_file); } else { @@ -159,6 +163,7 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) getAppName(), filename, GetLastError()); exit(1); } + reg_file = fopen(realname, "r"); if (reg_file == NULL) { @@ -166,8 +171,34 @@ static BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) fprintf(stderr, "%s: Can't open file \"%s\"\n", getAppName(), filename); exit(1); } + + if (silent == FALSE) + { + if (MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_BOX_TEXT), + MAKEINTRESOURCEW(IDS_APP_TITLE), + MB_YESNO | MB_ICONEXCLAMATION) == IDYES) + { + if (import_registry_file(reg_file)) + { + MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_SUCCESS_BOX_TEXT), + MAKEINTRESOURCEW(IDS_APP_TITLE), + MB_OK | MB_ICONINFORMATION); + } + else + { + MessageBoxW(NULL, MAKEINTRESOURCEW(IDS_IMPORT_FAIL_BOX_TEXT), + MAKEINTRESOURCEW(IDS_APP_TITLE), + MB_OK | MB_ICONERROR); + } + } + } + else + { + import_registry_file(reg_file); + } + } - import_registry_file(reg_file); + if (realname) { HeapFree(GetProcessHeap(),0,realname); @@ -252,6 +283,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) REGEDIT_ACTION action = ACTION_UNDEF; LPSTR s = lpCmdLine; /* command line pointer */ CHAR ch = *s; /* current character */ + BOOL silent = FALSE; while (ch && ((ch == '-') || (ch == '/'))) { char chu; @@ -268,8 +300,8 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) ch2 = *(s+1); chu = toupper(ch); if (!ch2 || isspace(ch2)) { - if (chu == 'S' || chu == 'V') { - /* ignore these switches */ + if (chu == 'V') { + /* ignore this switch */ } else { switch (chu) { case 'D': @@ -278,6 +310,9 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) case 'E': action = ACTION_EXPORT; break; + case 'S': + silent = TRUE; + break; case '?': fprintf(stderr,usage); exit(0); @@ -323,5 +358,5 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine) if (action == ACTION_UNDEF) return FALSE; - return PerformRegAction(action, s); + return PerformRegAction(action, s, silent); } diff --git a/programs/regedit/regedit.rc b/programs/regedit/regedit.rc index 8d3b333..ed04a00 100644 --- a/programs/regedit/regedit.rc +++ b/programs/regedit/regedit.rc @@ -188,6 +188,13 @@ END STRINGTABLE BEGIN + IDS_IMPORT_BOX_TEXT "Are you sure you want to add file informations to the registry?" + IDS_IMPORT_SUCCESS_BOX_TEXT "Values successfuly added to the registry" + IDS_IMPORT_FAIL_BOX_TEXT "Failed to add values to the registry" +END + +STRINGTABLE +BEGIN IDS_FILEDIALOG_IMPORT_TITLE "Import Registry File" IDS_FILEDIALOG_EXPORT_TITLE "Export Registry File" IDS_FILEDIALOG_FILTER_REG "Registry files (*.reg)" diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h index 020765e..a520850 100644 --- a/programs/regedit/resource.h +++ b/programs/regedit/resource.h @@ -58,6 +58,9 @@ #define IDS_REGISTRY_VALUE_NOT_SET 162 #define IDS_REGISTRY_VALUE_CANT_DISPLAY 164 #define IDS_REGISTRY_UNKNOWN_TYPE 165 +#define IDS_IMPORT_BOX_TEXT 304 +#define IDS_IMPORT_SUCCESS_BOX_TEXT 305 +#define IDS_IMPORT_FAIL_BOX_TEXT 306 #define IDC_LICENSE_EDIT 1029 #define ID_REGISTRY_EXIT 32770 #define ID_FAVORITES_ADDTOFAVORITES 32772 -- 1.7.4.1
