Lightweight sync with WINE regedit; imported obvious changes such as
const correctness, TCHAR string usage etc
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
Modified: trunk/reactos/subsys/system/regedit/regedit.c
Modified: trunk/reactos/subsys/system/regedit/regproc.c
Modified: trunk/reactos/subsys/system/regedit/regproc.h
Modified: trunk/reactos/subsys/system/regedit/treeview.c
_____
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
--- trunk/reactos/subsys/system/regedit/childwnd.c 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/childwnd.c 2005-09-25
16:56:52 UTC (rev 18056)
@@ -42,6 +42,7 @@
if (hRootKey == HKEY_LOCAL_MACHINE) return
_T("HKEY_LOCAL_MACHINE");
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
if (hRootKey == HKEY_CURRENT_CONFIG) return
_T("HKEY_CURRENT_CONFIG");
+ if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
return _T("UKNOWN HKEY, PLEASE REPORT");
}
@@ -169,8 +170,7 @@
* WM_DESTROY - post a quit message and return
*
*/
-LRESULT CALLBACK
-ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
static short last_split;
BOOL Result;
_____
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
--- trunk/reactos/subsys/system/regedit/framewnd.c 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/framewnd.c 2005-09-25
16:56:52 UTC (rev 18056)
@@ -61,7 +61,7 @@
MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top,
prect->right, prect->bottom, TRUE);
}
-void resize_frame_client(HWND hWnd)
+static void resize_frame_client(HWND hWnd)
{
RECT rect;
@@ -183,7 +183,7 @@
return TRUE;
}
-UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg,
WPARAM wParam, LPARAM lParam)
+static UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT
uiMsg, WPARAM wParam, LPARAM lParam)
{
OPENFILENAME* pOpenFileName;
OFNOTIFY* pOfNotify;
@@ -375,7 +375,7 @@
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
- if (PrintDlg(&pd) == TRUE) {
+ if (PrintDlg(&pd)) {
/* GDI calls to render output. */
DeleteDC(pd.hDC); /* Delete DC when done.*/
}
@@ -424,7 +424,7 @@
return TRUE;
}
-BOOL CopyKeyName(HWND hWnd, LPTSTR keyName)
+static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
{
BOOL result;
@@ -717,8 +717,7 @@
*
*/
-LRESULT CALLBACK
-FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message) {
case WM_CREATE:
@@ -730,6 +729,10 @@
if (!_CmdWndProc(hWnd, message, wParam, lParam))
return DefWindowProc(hWnd, message, wParam, lParam);
break;
+ case WM_ACTIVATE:
+ if (LOWORD(hWnd))
+ SetFocus(g_pChildWnd->hWnd);
+ break;
case WM_SIZE:
resize_frame_client(hWnd);
break;
@@ -744,10 +747,6 @@
case WM_MENUSELECT:
OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam),
(HMENU)lParam);
break;
- case WM_ACTIVATE:
- if (LOWORD(hWnd))
- SetFocus(g_pChildWnd->hWnd);
- break;
case WM_DESTROY:
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
PostQuitMessage(0);
_____
Modified: trunk/reactos/subsys/system/regedit/regedit.c
--- trunk/reactos/subsys/system/regedit/regedit.c 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/regedit.c 2005-09-25
16:56:52 UTC (rev 18056)
@@ -23,7 +23,7 @@
#include <windows.h>
#include "regproc.h"
-static char *usage =
+static const char *usage =
"Usage:\n"
" regedit filename\n"
" regedit /E filename [regpath]\n"
@@ -52,8 +52,7 @@
"\n"
"The switches are case-insensitive, can be prefixed either by '-'
or '/'.\n"
"This program is command-line compatible with Microsoft Windows\n"
- "regedit. The difference with Windows regedit - this application
has\n"
- "command-line interface only.\n";
+ "regedit.\n";
typedef enum {
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
@@ -68,7 +67,7 @@
* chu - the switch character in upper-case.
* s - the command line string where s points to the switch
character.
*/
-void error_unknown_switch(char chu, char *s)
+static void error_unknown_switch(char chu, char *s)
{
if (isalpha(chu)) {
fprintf(stderr,"%s: Undefined switch /%c!\n", getAppName(),
chu);
_____
Modified: trunk/reactos/subsys/system/regedit/regproc.c
--- trunk/reactos/subsys/system/regedit/regproc.c 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/regproc.c 2005-09-25
16:56:52 UTC (rev 18056)
@@ -46,18 +46,18 @@
static HKEY currentKeyHandle = 0;
static BOOL bTheKeyIsOpen = FALSE;
-static CHAR *app_name = "UNKNOWN";
+static const CHAR *app_name = "UNKNOWN";
-static CHAR *reg_class_names[] = {
+static const CHAR *reg_class_names[] = {
"HKEY_LOCAL_MACHINE",
"HKEY_USERS", "HKEY_CLASSES_ROOT",
- "HKEY_CURRENT_CONFIG",
"HKEY_CURRENT_USER"
+ "HKEY_CURRENT_CONFIG",
"HKEY_CURRENT_USER", "HKEY_DYN_DATA"
};
#define REG_CLASS_NUMBER (sizeof(reg_class_names) /
sizeof(reg_class_names[0]))
static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT,
- HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER
+ HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
};
/* return values */
@@ -234,7 +234,7 @@
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen)
{
char *s = str; /* Pointer to current */
- char *b = (char*)buf; /* Pointer to result */
+ char *b = (char*) buf; /* Pointer to result */
ULONG strLen = strlen(str);
ULONG strPos = 0;
@@ -346,7 +346,7 @@
/***********************************************************************
*******
* Replaces escape sequences with the characters.
*/
-void REGPROC_unescape_string(LPSTR str)
+static void REGPROC_unescape_string(LPSTR str)
{
int str_idx = 0; /* current character under analysis */
int val_idx = 0; /* the last character of the unescaped
string */
@@ -427,7 +427,7 @@
}
}
- hRes = RegSetValueExA(
+ hRes = RegSetValueEx(
currentKeyHandle,
val_name,
0, /* Reserved */
@@ -522,14 +522,14 @@
{
LPSTR classNameEnd;
LPSTR classNameBeg;
- UINT i;
+ unsigned int i;
char lpClassCopy[KEY_MAX_LEN];
if (lpClass == NULL)
return (HKEY)ERROR_INVALID_PARAMETER;
- strncpy(lpClassCopy, lpClass, KEY_MAX_LEN);
+ lstrcpynA(lpClassCopy, lpClass, KEY_MAX_LEN);
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name
ends by '\' */
if (!classNameEnd) /* or the whole
string */
@@ -558,7 +558,7 @@
/***********************************************************************
*******
* Close the currently opened key.
*/
-void closeKey()
+void closeKey(void)
{
RegCloseKey(currentKeyHandle);
@@ -579,7 +579,7 @@
void doSetValue(LPSTR stdInput)
{
/*
- * We encoutered the end of the file, make sure we
+ * We encountered the end of the file, make sure we
* close the opened key and exit
*/
if (stdInput == NULL) {
@@ -610,14 +610,14 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the queryValue type of
action. It
+ * This function is the main entry point to the queryValue type of
action. It
* receives the currently read line and dispatch the work depending on
the
* context.
*/
void doQueryValue(LPSTR stdInput)
{
/*
- * We encoutered the end of the file, make sure we
+ * We encountered the end of the file, make sure we
* close the opened key and exit
*/
if (stdInput == NULL) {
@@ -648,7 +648,7 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the deletetValue type of
action. It
+ * This function is the main entry point to the deleteValue type of
action. It
* receives the currently read line and dispatch the work depending on
the
* context.
*/
@@ -658,7 +658,7 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the deleteKey type of
action. It
+ * This function is the main entry point to the deleteKey type of
action. It
* receives the currently read line and dispatch the work depending on
the
* context.
*/
@@ -668,7 +668,7 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the createKey type of
action. It
+ * This function is the main entry point to the createKey type of
action. It
* receives the currently read line and dispatch the work depending on
the
* context.
*/
@@ -793,8 +793,7 @@
if (hRes == ERROR_SUCCESS) {
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
- strncpy(lpsRes, lpsData, lLen);
- lpsRes[lLen-1]='\0';
+ lstrcpynA(lpsRes, lpsData, lLen);
}
} else {
DWORD dwLen = KEY_MAX_LEN;
@@ -824,8 +823,7 @@
case REG_SZ:
case REG_EXPAND_SZ: {
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
- strncpy(lpsRes, lpbData, dwLen);
- lpsRes[dwLen-1]='\0';
+ lstrcpynA(lpsRes, lpbData, dwLen);
break;
}
case REG_DWORD: {
@@ -976,7 +974,7 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the registerDLL action. It
+ * This function is the main entry point to the registerDLL action. It
* receives the currently read line, then loads and registers the
requested DLLs
*/
void doRegisterDLL(LPSTR stdInput)
@@ -989,7 +987,7 @@
return;
/* Load and register the library, then free it */
- theLib = LoadLibraryA(stdInput);
+ theLib = LoadLibrary(stdInput);
if (theLib) {
FARPROC lpfnDLLRegProc = GetProcAddress(theLib,
"DllRegisterServer");
if (lpfnDLLRegProc)
@@ -1009,7 +1007,7 @@
}
/***********************************************************************
*******
- * This funtion is the main entry point to the unregisterDLL action.
It
+ * This function is the main entry point to the unregisterDLL action.
It
* receives the currently read line, then loads and unregisters the
requested DLLs
*/
void doUnregisterDLL(LPSTR stdInput)
@@ -1022,7 +1020,7 @@
return;
/* Load and unregister the library, then free it */
- theLib = LoadLibraryA(stdInput);
+ theLib = LoadLibrary(stdInput);
if (theLib) {
FARPROC lpfnDLLRegProc = GetProcAddress(theLib,
"DllUnregisterServer");
if (lpfnDLLRegProc)
@@ -1047,7 +1045,7 @@
* Print the message for GetLastError
*/
-void REGPROC_print_error()
+static void REGPROC_print_error(void)
{
LPVOID lpMsgBuf;
DWORD error_code;
@@ -1076,7 +1074,7 @@
* required_len - length of the string to place to the buffer in
characters.
* The length does not include the terminating null character.
*/
-void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD
required_len)
+static void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD
required_len)
{
required_len++;
if (required_len > *len) {
@@ -1092,7 +1090,7 @@
/***********************************************************************
*******
* Prints string str to file
*/
-void REGPROC_export_string(FILE *file, CHAR *str)
+static void REGPROC_export_string(FILE *file, CHAR *str)
{
size_t len = strlen(str);
size_t i;
@@ -1133,7 +1131,7 @@
* Is resized if necessary.
* val_size - size of the buffer for storing values in bytes.
*/
-void export_hkey(FILE *file, HKEY key,
+static void export_hkey(FILE *file, HKEY key,
CHAR **reg_key_name_buf, DWORD *reg_key_name_len,
CHAR **val_name_buf, DWORD *val_name_len,
BYTE **val_buf, DWORD *val_size)
@@ -1176,8 +1174,8 @@
DWORD value_type;
DWORD val_name_len1 = *val_name_len;
DWORD val_size1 = *val_size;
- ret = RegEnumValueA(key, i, *val_name_buf, &val_name_len1,
NULL,
- &value_type, *val_buf, &val_size1);
+ ret = RegEnumValue(key, i, *val_name_buf, &val_name_len1, NULL,
+ &value_type, *val_buf, &val_size1);
if (ret != ERROR_SUCCESS) {
more_data = FALSE;
if (ret != ERROR_NO_MORE_ITEMS) {
@@ -1198,7 +1196,7 @@
case REG_SZ:
case REG_EXPAND_SZ:
fputs("\"", file);
- REGPROC_export_string(file, (CHAR*)*val_buf);
+ REGPROC_export_string(file, (char*) *val_buf);
fputs("\"\n", file);
break;
@@ -1217,7 +1215,7 @@
/* falls through */
case REG_BINARY: {
DWORD i1;
- CHAR *hex_prefix;
+ const CHAR *hex_prefix;
CHAR buf[20];
int cur_pos;
@@ -1260,8 +1258,8 @@
while(more_data) {
DWORD buf_len = *reg_key_name_len - curr_len;
- ret = RegEnumKeyExA(key, i, *reg_key_name_buf + curr_len + 1,
&buf_len,
- NULL, NULL, NULL, NULL);
+ ret = RegEnumKeyEx(key, i, *reg_key_name_buf + curr_len + 1,
&buf_len,
+ NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) {
more_data = FALSE;
if (ret != ERROR_NO_MORE_ITEMS) {
@@ -1271,8 +1269,8 @@
HKEY subkey;
i++;
- if (RegOpenKeyA(key, *reg_key_name_buf + curr_len + 1,
- &subkey) == ERROR_SUCCESS) {
+ if (RegOpenKey(key, *reg_key_name_buf + curr_len + 1,
+ &subkey) == ERROR_SUCCESS) {
export_hkey(file, subkey, reg_key_name_buf,
reg_key_name_len,
val_name_buf, val_name_len, val_buf,
val_size);
RegCloseKey(subkey);
@@ -1287,7 +1285,7 @@
/***********************************************************************
*******
* Open file for export.
*/
-FILE *REGPROC_open_export_file(CHAR *file_name)
+static FILE *REGPROC_open_export_file(CHAR *file_name)
{
FILE *file = fopen(file_name, "w");
if (!file) {
@@ -1350,7 +1348,7 @@
®_key_name_buf, ®_key_name_len,
&val_name_buf, &val_name_len,
&val_buf, &val_size);
- } else if (RegOpenKeyA(reg_key_class, branch_name, &key) ==
ERROR_SUCCESS) {
+ } else if (RegOpenKey(reg_key_class, branch_name, &key) ==
ERROR_SUCCESS) {
file = REGPROC_open_export_file(file_name);
export_hkey(file, key,
®_key_name_buf, ®_key_name_len,
@@ -1372,7 +1370,8 @@
/* do not export HKEY_CLASSES_ROOT */
if (reg_class_keys[i] != HKEY_CLASSES_ROOT &&
reg_class_keys[i] != HKEY_CURRENT_USER &&
- reg_class_keys[i] != HKEY_CURRENT_CONFIG) {
+ reg_class_keys[i] != HKEY_CURRENT_CONFIG &&
+ reg_class_keys[i] != HKEY_DYN_DATA) {
strcpy(reg_key_name_buf, reg_class_names[i]);
export_hkey(file, reg_class_keys[i],
®_key_name_buf, ®_key_name_len,
@@ -1393,7 +1392,7 @@
/***********************************************************************
*******
* Reads contents of the specified file into the registry.
*/
-BOOL import_registry_file(LPSTR filename)
+BOOL import_registry_file(LPTSTR filename)
{
FILE* reg_file = fopen(filename, "r");
@@ -1407,7 +1406,7 @@
/***********************************************************************
*******
* Recursive function which removes the registry key with all subkeys.
*/
-void delete_branch(HKEY key,
+static void delete_branch(HKEY key,
CHAR **reg_key_name_buf, DWORD *reg_key_name_len)
{
HKEY branch_key;
@@ -1417,7 +1416,7 @@
LONG ret;
long int i;
- if (RegOpenKeyA(key, *reg_key_name_buf, &branch_key) !=
ERROR_SUCCESS) {
+ if (RegOpenKey(key, *reg_key_name_buf, &branch_key) !=
ERROR_SUCCESS) {
REGPROC_print_error();
}
@@ -1436,8 +1435,8 @@
for (i = subkeys - 1; i >= 0; i--) {
DWORD buf_len = *reg_key_name_len - curr_len;
- ret = RegEnumKeyExA(branch_key, i, *reg_key_name_buf + curr_len
+ 1,
- &buf_len, NULL, NULL, NULL, NULL);
+ ret = RegEnumKeyEx(branch_key, i, *reg_key_name_buf + curr_len
+ 1,
+ &buf_len, NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS &&
ret != ERROR_MORE_DATA &&
ret != ERROR_NO_MORE_ITEMS) {
@@ -1448,7 +1447,7 @@
}
(*reg_key_name_buf)[curr_len] = '\0';
RegCloseKey(branch_key);
- RegDeleteKeyA(key, *reg_key_name_buf);
+ RegDeleteKey(key, *reg_key_name_buf);
}
/***********************************************************************
*******
@@ -1482,7 +1481,7 @@
getAppName(), reg_key_name);
exit(1);
}
- if (RegOpenKeyA(reg_key_class, branch_name, &branch_key) ==
ERROR_SUCCESS) {
+ if (RegOpenKey(reg_key_class, branch_name, &branch_key) ==
ERROR_SUCCESS) {
/* check whether the key exists */
RegCloseKey(branch_key);
delete_branch(reg_key_class, &branch_name, &branch_name_len);
@@ -1494,12 +1493,12 @@
* Sets the application name. Then application name is used in the
error
* reporting.
*/
-void setAppName(CHAR *name)
+void setAppName(const CHAR *name)
{
app_name = name;
}
-CHAR *getAppName()
+const CHAR *getAppName(void)
{
return app_name;
}
_____
Modified: trunk/reactos/subsys/system/regedit/regproc.h
--- trunk/reactos/subsys/system/regedit/regproc.h 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/regproc.h 2005-09-25
16:56:52 UTC (rev 18056)
@@ -39,11 +39,11 @@
void doUnregisterDLL(LPSTR lpsLine);
BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name);
-BOOL import_registry_file(LPSTR filename);
+BOOL import_registry_file(LPTSTR filename);
void delete_registry_key(CHAR *reg_key_name);
-void setAppName(CHAR *name);
-CHAR *getAppName();
+void setAppName(const CHAR *name);
+const CHAR *getAppName(void);
void processRegLines(FILE *in, CommandAPI command);
@@ -61,7 +61,7 @@
DWORD getDataType(LPSTR *lpValue, DWORD* parse_type);
LPSTR getArg(LPSTR arg);
HRESULT openKey(LPSTR stdInput);
-void closeKey();
+void closeKey(void);
/*
* api setValue prototypes
_____
Modified: trunk/reactos/subsys/system/regedit/treeview.c
--- trunk/reactos/subsys/system/regedit/treeview.c 2005-09-25
15:59:38 UTC (rev 18055)
+++ trunk/reactos/subsys/system/regedit/treeview.c 2005-09-25
16:56:52 UTC (rev 18056)
@@ -100,7 +100,6 @@
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
if (!hItem) return NULL;
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen,
&maxLen)) return NULL;
- /*printf("hRoot=%p, keyPath='%s'\n", *phRootKey, pathBuffer);*/
return pathBuffer;
}