ReactOS 0.4.15-dev-5664-g3bf4ef6
regdump.c
Go to the documentation of this file.
1/*
2 * ReactOS regedit
3 *
4 * regdump.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <windows.h>
24#include <tchar.h>
25#include <stdio.h>
26#include "regdump.h"
27
28
29#ifdef UNICODE
30//#define dprintf _tprintf
31#define dprintf printf
32#else
33#define dprintf printf
34#endif
35
37
38
39
40const char* default_cmd_line1 = "/E HKLM_EXPORT.TXT HKEY_LOCAL_MACHINE";
41const char* default_cmd_line2 = "TEST_IMPORT.TXT";
42const char* default_cmd_line3 = "/P HKEY_LOCAL_MACHINE\\SYSTEM";
43const char* default_cmd_line4 = "/P HKEY_LOCAL_MACHINE\\SOFTWARE";
44const char* default_cmd_line5 = "/P HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
45const char* default_cmd_line6 = "/E HKCR_EXPORT.TXT HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
46const char* default_cmd_line7 = "/D HKEY_LOCAL_MACHINE\\SYSTEM";
47const char* default_cmd_line8 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
48const char* default_cmd_line9 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
49
50/* Show usage */
51void usage(const char* appName)
52{
53 fprintf(stderr, "%s: Dump registry key to console\n", appName);
54 fprintf(stderr, "%s HKCR | HKCU | HKLM | HKU | HKCC | HKRR\n", appName);
55}
56
57void show_menu(void)
58{
59 _tprintf(_T("\nchoose test :\n"));
60 _tprintf(_T(" 0 = Exit\n"));
61 printf(" 1 = %s\n", default_cmd_line1);
62 printf(" 2 = %s\n", default_cmd_line2);
63 printf(" 3 = %s\n", default_cmd_line3);
64 printf(" 4 = %s\n", default_cmd_line4);
65 printf(" 5 = %s\n", default_cmd_line5);
66 printf(" 6 = %s\n", default_cmd_line6);
67 printf(" 7 = %s\n", default_cmd_line7);
68 printf(" 8 = %s\n", default_cmd_line8);
69 printf(" 9 = %s\n", default_cmd_line9);
70/*
71 _tprintf(_T(" 1 = %s\n"), default_cmd_line1);
72 _tprintf(_T(" 2 = %s\n"), default_cmd_line2);
73 _tprintf(_T(" 3 = %s\n"), default_cmd_line3);
74 _tprintf(_T(" 4 = %s\n"), default_cmd_line4);
75 _tprintf(_T(" 5 = %s\n"), default_cmd_line5);
76 _tprintf(_T(" 6 = %s\n"), default_cmd_line6);
77 _tprintf(_T(" 7 = %s\n"), default_cmd_line7);
78 _tprintf(_T(" 8 = %s\n"), default_cmd_line8);
79 _tprintf(_T(" 9 = %s\n"), default_cmd_line9);
80 */
81// _tprintf(_T(" A = HKEY_CLASSES_ROOT\n"));
82// _tprintf(_T(" B = HKEY_CURRENT_USER\n"));
83// _tprintf(_T(" C = HKEY_LOCAL_MACHINE\n"));
84// _tprintf(_T(" D = HKEY_USERS\n"));
85// _tprintf(_T(" E = HKEY_CURRENT_CONFIG\n"));
86// _tprintf(_T(" F = REGISTRY ROOT\n"));
87}
88
89int regdump(int argc, char* argv[])
90{
91 char Buffer[500];
92
93 if (argc > 1) {
94// if (0 == _tcsstr(argv[1], _T("HKLM"))) {
95 if (strstr(argv[1], "help")) {
96 usage(argv[0]);
97 } else if (strstr(argv[1], "HKCR")) {
98 RegKeyPrint('1');
99 } else if (strstr(argv[1], "HKCU")) {
100 RegKeyPrint('2');
101 } else if (strstr(argv[1], "HKLM")) {
102 RegKeyPrint('3');
103 } else if (strstr(argv[1], "HKU")) {
104 RegKeyPrint('4');
105 } else if (strstr(argv[1], "HKCC")) {
106 RegKeyPrint('5');
107 } else if (strstr(argv[1], "HKRR")) {
108 RegKeyPrint('6');
109 } else {
110 dprintf("started with argc = %d, argv[1] = %s (unknown?)\n", argc, argv[1]);
111 }
112 return 0;
113 }
114 show_menu();
115 while (1) {
116 GetInput(Buffer, sizeof(Buffer));
117 switch (toupper(Buffer[0])) {
118 case '0':
119 return(0);
120 case '1':
122 goto doit;
123 case '2':
125 goto doit;
126 case '3':
128 goto doit;
129 case '4':
131 goto doit;
132 case '5':
134 goto doit;
135 case '6':
137 goto doit;
138 case '7':
140 goto doit;
141 case '8':
143 goto doit;
144 case '9':
146 goto doit;
147 case 'A':
148 case 'B':
149 case 'C':
150 case 'D':
151 case 'E':
152 case 'F':
153 RegKeyPrint(toupper(Buffer[0]) - 'A' + 1);
154 break;
155 default: doit:
156 if (!ProcessCmdLine(Buffer)) {
157 dprintf("invalid input.\n");
158 show_menu();
159 } else {
160 dprintf("done.\n");
161 }
162 break;
163 }
164 }
165 return 0;
166}
static int argc
Definition: ServiceArgs.c:12
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
int toupper(int c)
Definition: utclib.c:881
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
Definition: bufpool.h:45
BOOL ProcessCmdLine(IN LPWSTR lpCmdLine)
Definition: eventvwr.c:184
#define doit(a, b)
Definition: fieldoff.c:4
#define printf
Definition: freeldr.h:94
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define _tprintf
Definition: tchar.h:506
const char * appName(const char *argv0)
Definition: loadlib.c:89
DWORD GetInput(char *Buffer, int buflen)
Definition: main.c:12
#define argv
Definition: mplay32.c:18
const char * default_cmd_line9
Definition: regdump.c:48
#define dprintf
Definition: regdump.c:33
const char * default_cmd_line3
Definition: regdump.c:42
const char * default_cmd_line7
Definition: regdump.c:46
const char * default_cmd_line1
Definition: regdump.c:40
const char * default_cmd_line6
Definition: regdump.c:45
const char * default_cmd_line2
Definition: regdump.c:41
void RegKeyPrint(int which)
const char * default_cmd_line4
Definition: regdump.c:43
const char * default_cmd_line5
Definition: regdump.c:44
const char * default_cmd_line8
Definition: regdump.c:47
void show_menu(void)
Definition: regdump.c:57
int regdump(int argc, char *argv[])
Definition: regdump.c:89
#define _T(x)
Definition: vfdio.h:22
static GLenum which
Definition: wgl_font.c:159