Only whitespace changes. Unfortunately, the formatting was all messed up by having tabs of 4 and 8 chars (I said it before, and I'll say it again: the only sane way of dealing with tabs is to always use the standard size of 8 chars. Anything else is too complicated to ever work reliably). ChangeLog Reformat regedit in a consistent manner. Index: programs/regedit/childwnd.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/childwnd.c,v retrieving revision 1.3 diff -u -r1.3 childwnd.c --- programs/regedit/childwnd.c 5 Dec 2003 00:09:54 -0000 1.3 +++ programs/regedit/childwnd.c 8 Dec 2003 04:51:04 -0000 @@ -56,25 +56,25 @@ static void draw_splitbar(HWND hWnd, int x) { - RECT rt; - HDC hdc = GetDC(hWnd); + RECT rt; + HDC hdc = GetDC(hWnd); - GetClientRect(hWnd, &rt); - rt.left = x - SPLIT_WIDTH/2; - rt.right = x + SPLIT_WIDTH/2+1; - InvertRect(hdc, &rt); - ReleaseDC(hWnd, hdc); + GetClientRect(hWnd, &rt); + rt.left = x - SPLIT_WIDTH/2; + rt.right = x + SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + ReleaseDC(hWnd, hdc); } static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy) { - HDWP hdwp = BeginDeferWindowPos(2); - RECT rt = {0, 0, cx, cy}; + HDWP hdwp = BeginDeferWindowPos(2); + RECT rt = {0, 0, cx, cy}; - cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2; + cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2; DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); - EndDeferWindowPos(hdwp); + EndDeferWindowPos(hdwp); } static void OnPaint(HWND hWnd) @@ -99,8 +99,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (LOWORD(wParam)) { - /* Parse the menu selections: */ + switch (LOWORD(wParam)) { + /* Parse the menu selections: */ case ID_REGISTRY_EXIT: DestroyWindow(hWnd); break; @@ -110,7 +110,7 @@ default: return FALSE; } - return TRUE; + return TRUE; } /******************************************************************************* @@ -127,12 +127,12 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static int last_split; -/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */ + /* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */ switch (message) { case WM_CREATE: pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams; - if (!pChildWnd) return 0; + if (!pChildWnd) return 0; pChildWnd->nSplitPos = 250; pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW); pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/); @@ -141,99 +141,99 @@ if (!_CmdWndProc(hWnd, message, wParam, lParam)) { goto def; } - break; + break; case WM_PAINT: OnPaint(hWnd); return 0; - case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT) { - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hWnd, &pt); - if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { - SetCursor(LoadCursor(0, IDC_SIZEWE)); - return TRUE; - } - } - goto def; + case WM_SETCURSOR: + if (LOWORD(lParam) == HTCLIENT) { + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hWnd, &pt); + if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { + SetCursor(LoadCursor(0, IDC_SIZEWE)); + return TRUE; + } + } + goto def; case WM_DESTROY: PostQuitMessage(0); break; - case WM_LBUTTONDOWN: { - RECT rt; - int x = LOWORD(lParam); - GetClientRect(hWnd, &rt); - if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { - last_split = pChildWnd->nSplitPos; - draw_splitbar(hWnd, last_split); - SetCapture(hWnd); - } - break;} - - case WM_LBUTTONUP: - if (GetCapture() == hWnd) { - RECT rt; - int x = LOWORD(lParam); - draw_splitbar(hWnd, last_split); - last_split = -1; - GetClientRect(hWnd, &rt); - pChildWnd->nSplitPos = x; - ResizeWnd(pChildWnd, rt.right, rt.bottom); - ReleaseCapture(); - } - break; - - case WM_CAPTURECHANGED: - if (GetCapture()==hWnd && last_split>=0) - draw_splitbar(hWnd, last_split); - break; + case WM_LBUTTONDOWN: { + RECT rt; + int x = LOWORD(lParam); + GetClientRect(hWnd, &rt); + if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { + last_split = pChildWnd->nSplitPos; + draw_splitbar(hWnd, last_split); + SetCapture(hWnd); + } + break; + } + + case WM_LBUTTONUP: + if (GetCapture() == hWnd) { + RECT rt; + int x = LOWORD(lParam); + draw_splitbar(hWnd, last_split); + last_split = -1; + GetClientRect(hWnd, &rt); + pChildWnd->nSplitPos = x; + ResizeWnd(pChildWnd, rt.right, rt.bottom); + ReleaseCapture(); + } + break; + + case WM_CAPTURECHANGED: + if (GetCapture()==hWnd && last_split>=0) + draw_splitbar(hWnd, last_split); + break; case WM_KEYDOWN: - if (wParam == VK_ESCAPE) - if (GetCapture() == hWnd) { - RECT rt; - draw_splitbar(hWnd, last_split); - GetClientRect(hWnd, &rt); + if (wParam == VK_ESCAPE) + if (GetCapture() == hWnd) { + RECT rt; + draw_splitbar(hWnd, last_split); + GetClientRect(hWnd, &rt); ResizeWnd(pChildWnd, rt.right, rt.bottom); - last_split = -1; - ReleaseCapture(); - SetCursor(LoadCursor(0, IDC_ARROW)); - } - break; - - case WM_MOUSEMOVE: - if (GetCapture() == hWnd) { - RECT rt; - int x = LOWORD(lParam); - HDC hdc = GetDC(hWnd); - GetClientRect(hWnd, &rt); - rt.left = last_split-SPLIT_WIDTH/2; - rt.right = last_split+SPLIT_WIDTH/2+1; - InvertRect(hdc, &rt); - last_split = x; - rt.left = x-SPLIT_WIDTH/2; - rt.right = x+SPLIT_WIDTH/2+1; - InvertRect(hdc, &rt); - ReleaseDC(hWnd, hdc); - } - break; + last_split = -1; + ReleaseCapture(); + SetCursor(LoadCursor(0, IDC_ARROW)); + } + break; + + case WM_MOUSEMOVE: + if (GetCapture() == hWnd) { + RECT rt; + int x = LOWORD(lParam); + HDC hdc = GetDC(hWnd); + GetClientRect(hWnd, &rt); + rt.left = last_split-SPLIT_WIDTH/2; + rt.right = last_split+SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + last_split = x; + rt.left = x-SPLIT_WIDTH/2; + rt.right = x+SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + ReleaseDC(hWnd, hdc); + } + break; - case WM_SETFOCUS: + case WM_SETFOCUS: if (pChildWnd != NULL) { - SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd); + SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd); } - break; + break; case WM_TIMER: break; - case WM_NOTIFY: + case WM_NOTIFY: if ((int)wParam == TREE_WINDOW) { switch (((LPNMHDR)lParam)->code) { case TVN_ITEMEXPANDING: return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); - case TVN_SELCHANGED: - { + case TVN_SELCHANGED: { HKEY hKey; TCHAR keyPath[1000]; int keyPathLen = 0; @@ -251,20 +251,20 @@ goto def; } } else - if ((int)wParam == LIST_WINDOW) { - if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) { - goto def; + if ((int)wParam == LIST_WINDOW) { + if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) { + goto def; + } } - } break; - case WM_SIZE: + case WM_SIZE: if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) { - ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam)); + ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam)); } /* fall through */ - default: def: +default: def: return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; + } + return 0; } Index: programs/regedit/edit.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/edit.c,v retrieving revision 1.1 diff -u -r1.1 edit.c --- programs/regedit/edit.c 3 Dec 2003 20:25:24 -0000 1.1 +++ programs/regedit/edit.c 8 Dec 2003 04:51:04 -0000 @@ -47,10 +47,10 @@ hInstance = GetModuleHandle(0); if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title))) - lstrcpy(title, "Error"); + lstrcpy(title, "Error"); if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt))) - lstrcpy(errfmt, "Unknown error string!"); + lstrcpy(errfmt, "Unknown error string!"); va_start(ap, resId); _vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap); @@ -66,27 +66,27 @@ int len; switch(uMsg) { - case WM_INITDIALOG: - SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); - SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); - return TRUE; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) { - if ((len = GetWindowTextLength(hwndValue))) { - if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) { - stringValueData = valueData; - if (!GetWindowText(hwndValue, stringValueData, len + 1)) - *stringValueData = 0; - } - } - } - /* Fall through */ - case IDCANCEL: - EndDialog(hwndDlg, wParam); - return TRUE; - } + case WM_INITDIALOG: + SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName); + SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData); + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) { + if ((len = GetWindowTextLength(hwndValue))) { + if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) { + stringValueData = valueData; + if (!GetWindowText(hwndValue, stringValueData, len + 1)) + *stringValueData = 0; + } + } + } + /* Fall through */ + case IDCANCEL: + EndDialog(hwndDlg, wParam); + return TRUE; + } } return FALSE; } @@ -104,28 +104,28 @@ lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen); if (lRet != ERROR_SUCCESS) { - error(hwnd, IDS_BAD_VALUE, valueName); - goto done; + error(hwnd, IDS_BAD_VALUE, valueName); + goto done; } if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) { - if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen))) { - error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); - goto done; - } + if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen))) { + error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); + goto done; + } lRet = RegQueryValueEx(hKey, valueName, 0, 0, stringValueData, &valueDataLen); - if (lRet != ERROR_SUCCESS) { - error(hwnd, IDS_BAD_VALUE, valueName); - goto done; - } - if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) { - lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1); - if (lRet == ERROR_SUCCESS) result = TRUE; - } + if (lRet != ERROR_SUCCESS) { + error(hwnd, IDS_BAD_VALUE, valueName); + goto done; + } + if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) { + lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1); + if (lRet == ERROR_SUCCESS) result = TRUE; + } } else if ( type == REG_DWORD ) { - MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR); + MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR); } else { - error(hwnd, IDS_UNSUPPORTED_TYPE, type); + error(hwnd, IDS_UNSUPPORTED_TYPE, type); } done: Index: programs/regedit/framewnd.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/framewnd.c,v retrieving revision 1.3 diff -u -r1.3 framewnd.c --- programs/regedit/framewnd.c 5 Dec 2003 00:09:54 -0000 1.3 +++ programs/regedit/framewnd.c 8 Dec 2003 04:55:08 -0000 @@ -46,29 +46,29 @@ static void resize_frame_rect(HWND hWnd, PRECT prect) { - RECT rt; -/* - if (IsWindowVisible(hToolBar)) { - SendMessage(hToolBar, WM_SIZE, 0, 0); - GetClientRect(hToolBar, &rt); - prect->top = rt.bottom+3; - prect->bottom -= rt.bottom+3; - } - */ - if (IsWindowVisible(hStatusBar)) { - SetupStatusBar(hWnd, TRUE); - GetClientRect(hStatusBar, &rt); - prect->bottom -= rt.bottom; - } + RECT rt; + /* + if (IsWindowVisible(hToolBar)) { + SendMessage(hToolBar, WM_SIZE, 0, 0); + GetClientRect(hToolBar, &rt); + prect->top = rt.bottom+3; + prect->bottom -= rt.bottom+3; + } + */ + if (IsWindowVisible(hStatusBar)) { + SetupStatusBar(hWnd, TRUE); + GetClientRect(hStatusBar, &rt); + prect->bottom -= rt.bottom; + } MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE); } void resize_frame_client(HWND hWnd) { - RECT rect; + RECT rect; - GetClientRect(hWnd, &rect); - resize_frame_rect(hWnd, &rect); + GetClientRect(hWnd, &rect); + resize_frame_rect(hWnd, &rect); } /********************************************************************************/ @@ -88,8 +88,8 @@ { bInMenuLoop = FALSE; /* Update the status bar pane sizes*/ - SetupStatusBar(hWnd, TRUE); - UpdateStatusBar(); + SetupStatusBar(hWnd, TRUE); + UpdateStatusBar(); } static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) @@ -119,70 +119,70 @@ int nParts; GetClientRect(hWnd, &rc); nParts = rc.right; -/* nParts = -1;*/ - if (bResize) - SendMessage(hStatusBar, WM_SIZE, 0, 0); - SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); + /* nParts = -1;*/ + if (bResize) + SendMessage(hStatusBar, WM_SIZE, 0, 0); + SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); } void UpdateStatusBar(void) { TCHAR text[260]; - DWORD size; + DWORD size; - size = sizeof(text)/sizeof(TCHAR); - GetComputerName(text, &size); + size = sizeof(text)/sizeof(TCHAR); + GetComputerName(text, &size); SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text); } static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) { - BOOL vis = IsWindowVisible(hchild); - HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); + BOOL vis = IsWindowVisible(hchild); + HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); - CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); - ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); - resize_frame_client(hWnd); + CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); + ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); + resize_frame_client(hWnd); } static BOOL CheckCommDlgError(HWND hWnd) { - DWORD dwErrorCode = CommDlgExtendedError(); - switch (dwErrorCode) { - case CDERR_DIALOGFAILURE: - break; - case CDERR_FINDRESFAILURE: - break; - case CDERR_NOHINSTANCE: - break; - case CDERR_INITIALIZATION: - break; - case CDERR_NOHOOK: - break; - case CDERR_LOCKRESFAILURE: - break; - case CDERR_NOTEMPLATE: - break; - case CDERR_LOADRESFAILURE: - break; - case CDERR_STRUCTSIZE: - break; - case CDERR_LOADSTRFAILURE: - break; - case FNERR_BUFFERTOOSMALL: - break; - case CDERR_MEMALLOCFAILURE: - break; - case FNERR_INVALIDFILENAME: - break; - case CDERR_MEMLOCKFAILURE: - break; - case FNERR_SUBCLASSFAILURE: - break; - default: - break; - } - return TRUE; + DWORD dwErrorCode = CommDlgExtendedError(); + switch (dwErrorCode) { + case CDERR_DIALOGFAILURE: + break; + case CDERR_FINDRESFAILURE: + break; + case CDERR_NOHINSTANCE: + break; + case CDERR_INITIALIZATION: + break; + case CDERR_NOHOOK: + break; + case CDERR_LOCKRESFAILURE: + break; + case CDERR_NOTEMPLATE: + break; + case CDERR_LOADRESFAILURE: + break; + case CDERR_STRUCTSIZE: + break; + case CDERR_LOADSTRFAILURE: + break; + case FNERR_BUFFERTOOSMALL: + break; + case CDERR_MEMALLOCFAILURE: + break; + case FNERR_INVALIDFILENAME: + break; + case CDERR_MEMLOCKFAILURE: + break; + case FNERR_SUBCLASSFAILURE: + break; + default: + break; + } + return TRUE; } UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) @@ -196,8 +196,7 @@ break; case WM_NOTIFY: pOfNotify = (OFNOTIFY*)lParam; - if (pOfNotify->hdr.code == CDN_INITDONE) { - } + if (pOfNotify->hdr.code == CDN_INITDONE) {} break; default: break; @@ -225,19 +224,19 @@ pofn->nMaxFile = _MAX_PATH; pofn->lpstrFileTitle = FileTitleBuffer; pofn->nMaxFileTitle = _MAX_PATH; -/* pofn->lpstrInitialDir = _T("");*/ -/* pofn->lpstrTitle = _T("Import Registry File");*/ -/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/ + /* pofn->lpstrInitialDir = _T("");*/ + /* pofn->lpstrTitle = _T("Import Registry File");*/ + /* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/ pofn->Flags = OFN_HIDEREADONLY; -/* pofn->nFileOffset = ;*/ -/* pofn->nFileExtension = ;*/ -/* pofn->lpstrDefExt = _T("");*/ -/* pofn->lCustData = ;*/ -/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/ -/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/ -/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/ -/* pofn->FlagsEx = ;*/ - return TRUE; + /* pofn->nFileOffset = ;*/ + /* pofn->nFileExtension = ;*/ + /* pofn->lpstrDefExt = _T("");*/ + /* pofn->lCustData = ;*/ + /* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/ + /* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/ + /* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/ + /* pofn->FlagsEx = ;*/ + return TRUE; } static BOOL ImportRegistryFile(HWND hWnd) @@ -246,7 +245,7 @@ InitOpenFileName(hWnd, &ofn); ofn.lpstrTitle = _T("Import Registry File"); -/* ofn.lCustData = ;*/ + /* ofn.lCustData = ;*/ if (GetOpenFileName(&ofn)) { if (!import_registry_file(ofn.lpstrFile)) { /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/ @@ -269,10 +268,11 @@ get_file_name(&s, filename, MAX_PATH); } #endif + } else { CheckCommDlgError(hWnd); } - return TRUE; + return TRUE; } @@ -284,7 +284,7 @@ ExportKeyPath[0] = _T('\0'); InitOpenFileName(hWnd, &ofn); ofn.lpstrTitle = _T("Export Registry File"); -/* ofn.lCustData = ;*/ + /* ofn.lCustData = ;*/ ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER; ofn.lpfnHook = ImportRegistryFile_OFNHookProc; ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1); @@ -314,10 +314,11 @@ export_registry_key(filename, NULL); } #endif + } else { CheckCommDlgError(hWnd); } - return TRUE; + return TRUE; } BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) @@ -449,8 +450,8 @@ item = ListView_GetNextItem(pChildWnd->hListWnd, -1, LVNI_FOCUSED); if (item != -1) ListView_GetItemText(pChildWnd->hListWnd, item, 0, valueName, sizeof(valueName)/sizeof(TCHAR)); - switch (LOWORD(wParam)) { - /* Parse the menu selections:*/ + switch (LOWORD(wParam)) { + /* Parse the menu selections:*/ case ID_REGISTRY_IMPORTREGISTRYFILE: ImportRegistryFile(hWnd); break; @@ -465,9 +466,9 @@ PrintRegistryHive(hWnd, _T("")); break; case ID_EDIT_MODIFY: - if (ModifyValue(hWnd, hKey, valueName)) - RefreshListView(pChildWnd->hListWnd, hKeyRoot, keyPath); - break; + if (ModifyValue(hWnd, hKey, valueName)) + RefreshListView(pChildWnd->hListWnd, hKeyRoot, keyPath); + break; case ID_EDIT_COPYKEYNAME: CopyKeyName(hWnd, _T("")); break; @@ -485,27 +486,27 @@ case ID_VIEW_REFRESH: RefreshView(hWnd); break; -/* case ID_OPTIONS_TOOLBAR:*/ -/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ -/* break;*/ - case ID_VIEW_STATUSBAR: - toggle_child(hWnd, LOWORD(wParam), hStatusBar); + /* case ID_OPTIONS_TOOLBAR:*/ + /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ + /* break;*/ + case ID_VIEW_STATUSBAR: + toggle_child(hWnd, LOWORD(wParam), hStatusBar); break; case ID_HELP_HELPTOPICS: -/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/ - WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0); + /* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/ + WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0); break; case ID_HELP_ABOUT: #ifdef WINSHELLAPI -/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/ + /* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/ #else ShowAboutBox(hWnd); #endif break; default: result = FALSE; - } - + } + RegCloseKey(hKey); return result; } @@ -526,15 +527,14 @@ static ChildWnd* pChildWnd = NULL; switch (message) { - case WM_CREATE: - { - pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd)); - _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); - hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"), -/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/ - WS_CHILD|WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hWnd, (HMENU)0, hInst, pChildWnd); + case WM_CREATE: { + pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd)); + _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); + hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"), + /* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/ + WS_CHILD|WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWnd, (HMENU)0, hInst, pChildWnd); } break; case WM_COMMAND: @@ -565,6 +565,6 @@ PostQuitMessage(0); default: return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; + } + return 0; } Index: programs/regedit/listview.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/listview.c,v retrieving revision 1.1 diff -u -r1.1 listview.c --- programs/regedit/listview.c 7 Aug 2003 03:10:13 -0000 1.1 +++ programs/regedit/listview.c 8 Dec 2003 04:55:40 -0000 @@ -61,30 +61,28 @@ item.pszText = LPSTR_TEXTCALLBACK; item.iImage = 0; item.lParam = (LPARAM)dwValType; -/* item.lParam = (LPARAM)ValBuf; */ + /* item.lParam = (LPARAM)ValBuf; */ #if (_WIN32_IE >= 0x0300) item.iIndent = 0; #endif index = ListView_InsertItem(hwndLV, &item); if (index != -1) { -/* LPTSTR pszText = NULL; */ + /* LPTSTR pszText = NULL; */ LPTSTR pszText = _T("value"); switch (dwValType) { case REG_SZ: case REG_EXPAND_SZ: ListView_SetItemText(hwndLV, index, 2, ValBuf); break; - case REG_DWORD: - { + case REG_DWORD: { TCHAR buf[64]; wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf); ListView_SetItemText(hwndLV, index, 2, buf); } -/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ + /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ break; - case REG_BINARY: - { + case REG_BINARY: { unsigned int i; LPBYTE pData = (LPBYTE)ValBuf; LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1); @@ -96,7 +94,7 @@ } break; default: -/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */ + /* lpsRes = convertHexToHexCSV(lpbData, dwLen); */ ListView_SetItemText(hwndLV, index, 2, pszText); break; } @@ -153,9 +151,9 @@ case REG_DWORD: plvdi->item.pszText = _T("REG_DWORD"); break; -/* case REG_DWORD_LITTLE_ENDIAN: */ -/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */ -/* break; */ + /* case REG_DWORD_LITTLE_ENDIAN: */ + /* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */ + /* break; */ case REG_DWORD_BIG_ENDIAN: plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN"); break; @@ -199,97 +197,93 @@ #endif static void ListViewPopUpMenu(HWND hWnd, POINT pt) -{ -} +{} static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (LOWORD(wParam)) { -/* case ID_FILE_OPEN: */ -/* break; */ - default: + switch (LOWORD(wParam)) { + /* case ID_FILE_OPEN: */ + /* break; */ + default: return FALSE; - } - return TRUE; + } + return TRUE; } static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) { - case WM_COMMAND: + switch (message) { + case WM_COMMAND: if (!_CmdWndProc(hWnd, message, wParam, lParam)) { return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); } - break; + break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case LVN_GETDISPINFO: OnGetDispInfo((NMLVDISPINFO*)lParam); break; - case NM_DBLCLK: - { - NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam; - LVHITTESTINFO info; - - if (nmitem->hdr.hwndFrom != hWnd) break; -/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */ -/* if (nmitem->hdr.code != ???) break; */ + case NM_DBLCLK: { + NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam; + LVHITTESTINFO info; + + if (nmitem->hdr.hwndFrom != hWnd) break; + /* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */ + /* if (nmitem->hdr.code != ???) break; */ #ifdef _MSC_VER - switch (nmitem->uKeyFlags) { - case LVKF_ALT: /* The ALT key is pressed. */ - /* properties dialog box ? */ - break; - case LVKF_CONTROL: /* The CTRL key is pressed. */ - /* run dialog box for providing parameters... */ - break; - case LVKF_SHIFT: /* The SHIFT key is pressed. */ - break; - } + switch (nmitem->uKeyFlags) { + case LVKF_ALT: /* The ALT key is pressed. */ + /* properties dialog box ? */ + break; + case LVKF_CONTROL: /* The CTRL key is pressed. */ + /* run dialog box for providing parameters... */ + break; + case LVKF_SHIFT: /* The SHIFT key is pressed. */ + break; + } #endif - info.pt.x = nmitem->ptAction.x; - info.pt.y = nmitem->ptAction.y; - if (ListView_HitTest(hWnd, &info) != -1) { - LVITEM item; - item.mask = LVIF_PARAM; - item.iItem = info.iItem; - if (ListView_GetItem(hWnd, &item)) { + info.pt.x = nmitem->ptAction.x; + info.pt.y = nmitem->ptAction.y; + if (ListView_HitTest(hWnd, &info) != -1) { + LVITEM item; + item.mask = LVIF_PARAM; + item.iItem = info.iItem; + if (ListView_GetItem(hWnd, &item)) {} } } - } break; - case NM_RCLICK: - { - int idx; - LV_HITTESTINFO lvH; - NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam; - lvH.pt.x = pNm->ptAction.x; - lvH.pt.y = pNm->ptAction.y; - idx = ListView_HitTest(hWnd, &lvH); - if (idx != -1) { - POINT pt; - GetCursorPos(&pt); - ListViewPopUpMenu(hWnd, pt); - return idx; - } + case NM_RCLICK: { + int idx; + LV_HITTESTINFO lvH; + NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam; + lvH.pt.x = pNm->ptAction.x; + lvH.pt.y = pNm->ptAction.y; + idx = ListView_HitTest(hWnd, &lvH); + if (idx != -1) { + POINT pt; + GetCursorPos(&pt); + ListViewPopUpMenu(hWnd, pt); + return idx; + } } break; default: return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); } - break; - case WM_KEYDOWN: - if (wParam == VK_TAB) { - /*TODO: SetFocus(Globals.hDriveBar) */ - /*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */ - } + break; + case WM_KEYDOWN: + if (wParam == VK_TAB) { + /*TODO: SetFocus(Globals.hDriveBar) */ + /*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */ + } /* fall thru... */ default: return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); break; - } - return 0; + } + return 0; } @@ -301,21 +295,21 @@ /* Get the dimensions of the parent window's client area, and create the list view control. */ GetClientRect(hwndParent, &rcClient); hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"), - WS_VISIBLE | WS_CHILD | LVS_REPORT, - 0, 0, rcClient.right, rcClient.bottom, - hwndParent, (HMENU)id, hInst, NULL); + WS_VISIBLE | WS_CHILD | LVS_REPORT, + 0, 0, rcClient.right, rcClient.bottom, + hwndParent, (HMENU)id, hInst, NULL); ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT); /* Initialize the image list, and add items to the control. */ -/* - if (!InitListViewImageLists(hwndLV) || - !InitListViewItems(hwndLV, szName)) { - DestroyWindow(hwndLV); - return FALSE; - } - */ + /* + if (!InitListViewImageLists(hwndLV) || + !InitListViewItems(hwndLV, szName)) { + DestroyWindow(hwndLV); + return FALSE; + } + */ CreateListColumns(hwndLV); - g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc); + g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc); return hwndLV; } @@ -336,9 +330,9 @@ ShowWindow(hwndLV, SW_HIDE); /* get size information and resize the buffers if necessary */ errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, - &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); + &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); -#define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */ + #define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */ if (errCode == ERROR_SUCCESS) { TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE); @@ -347,10 +341,10 @@ DWORD dwValSize = max_val_size; DWORD dwIndex = 0L; DWORD dwValType; -/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */ -/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */ -/* } */ -/* dwValSize = max_val_size; */ + /* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */ + /* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */ + /* } */ + /* dwValSize = max_val_size; */ while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { ValBuf[dwValSize] = 0; AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize); @@ -363,7 +357,7 @@ HeapFree(GetProcessHeap(), 0, ValName); } /*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */ -/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */ + /* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */ ShowWindow(hwndLV, SW_SHOW); RegCloseKey(hNewKey); } Index: programs/regedit/main.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/main.c,v retrieving revision 1.5 diff -u -r1.5 main.c --- programs/regedit/main.c 3 Dec 2003 22:29:05 -0000 1.5 +++ programs/regedit/main.c 8 Dec 2003 04:51:04 -0000 @@ -67,42 +67,42 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wcFrame = { - sizeof(WNDCLASSEX), - CS_HREDRAW | CS_VREDRAW/*style*/, - FrameWndProc, - 0/*cbClsExtra*/, - 0/*cbWndExtra*/, - hInstance, - LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), - LoadCursor(0, IDC_ARROW), - 0/*hbrBackground*/, - 0/*lpszMenuName*/, - szFrameClass, - (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) - }; + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + FrameWndProc, + 0/*cbClsExtra*/, + 0/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szFrameClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + }; ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */ WNDCLASSEX wcChild = { - sizeof(WNDCLASSEX), - CS_HREDRAW | CS_VREDRAW/*style*/, - ChildWndProc, - 0/*cbClsExtra*/, - sizeof(HANDLE)/*cbWndExtra*/, - hInstance, - LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), - LoadCursor(0, IDC_ARROW), - 0/*hbrBackground*/, - 0/*lpszMenuName*/, - szChildClass, - (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + ChildWndProc, + 0/*cbClsExtra*/, + sizeof(HANDLE)/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szChildClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) - }; + }; ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */ hChildWndClass = hChildWndClass; /* warning eater */ - hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); + hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); @@ -113,9 +113,9 @@ } */ hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, - WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, hMenuFrame, hInstance, NULL/*lpParam*/); + WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; @@ -148,20 +148,20 @@ { MSG msg; HACCEL hAccel; -/* - int hCrt; - FILE *hf; - AllocConsole(); - hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); - hf = _fdopen(hCrt, "w"); - *stdout = *hf; - setvbuf(stdout, NULL, _IONBF, 0); - - wprintf(L"command line exit, hInstance = %d\n", hInstance); - getch(); - FreeConsole(); - return 0; - */ + /* + int hCrt; + FILE *hf; + AllocConsole(); + hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + hf = _fdopen(hCrt, "w"); + *stdout = *hf; + setvbuf(stdout, NULL, _IONBF, 0); + + wprintf(L"command line exit, hInstance = %d\n", hInstance); + getch(); + FreeConsole(); + return 0; + */ if (ProcessCmdLine(lpCmdLine)) { return 0; Index: programs/regedit/main.h =================================================================== RCS file: /var/cvs/wine/programs/regedit/main.h,v retrieving revision 1.6 diff -u -r1.6 main.h --- programs/regedit/main.h 3 Dec 2003 22:29:05 -0000 1.6 +++ programs/regedit/main.h 6 Dec 2003 06:54:56 -0000 @@ -29,7 +29,7 @@ #define LIST_WINDOW 2003 #define MAX_LOADSTRING 100 -#define SPLIT_WIDTH 5 +#define SPLIT_WIDTH 5 #define MAX_NAME_LEN 500 #define COUNT_OF(a) (sizeof(a)/sizeof(a[0])) @@ -37,23 +37,23 @@ /******************************************************************************/ enum OPTION_FLAGS { - OPTIONS_AUTO_REFRESH = 0x01, - OPTIONS_READ_ONLY_MODE = 0x02, - OPTIONS_CONFIRM_ON_DELETE = 0x04, - OPTIONS_SAVE_ON_EXIT = 0x08, + OPTIONS_AUTO_REFRESH = 0x01, + OPTIONS_READ_ONLY_MODE = 0x02, + OPTIONS_CONFIRM_ON_DELETE = 0x04, + OPTIONS_SAVE_ON_EXIT = 0x08, OPTIONS_DISPLAY_BINARY_DATA = 0x10, OPTIONS_VIEW_TREE_ONLY = 0x20, OPTIONS_VIEW_DATA_ONLY = 0x40, }; typedef struct { - HWND hWnd; + HWND hWnd; HWND hTreeWnd; HWND hListWnd; int nFocusPanel; /* 0: left 1: right */ - int nSplitPos; - WINDOWPLACEMENT pos; - TCHAR szPath[MAX_PATH]; + int nSplitPos; + WINDOWPLACEMENT pos; + TCHAR szPath[MAX_PATH]; } ChildWnd; extern ChildWnd* pChildWnd; Index: programs/regedit/regedit.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/regedit.c,v retrieving revision 1.8 diff -u -r1.8 regedit.c --- programs/regedit/regedit.c 5 Dec 2003 04:42:06 -0000 1.8 +++ programs/regedit/regedit.c 8 Dec 2003 04:51:04 -0000 @@ -24,36 +24,36 @@ #include "regproc.h" static char *usage = -"Usage:\n" -" regedit filename\n" -" regedit /E filename [regpath]\n" -" regedit /D regpath\n" -"\n" -"filename - registry file name\n" -"regpath - name of the registry key\n" -"\n" -"When is called without any switches adds contents of the specified\n" -"registry file to the registry\n" -"\n" -"Switches:\n" -" /E - exports contents of the specified registry key to the specified\n" -" 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" -" 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" -" Ignored. Exists for compatibility with Windows regedit.\n" -" /R - location of user.dat file. Can be used with any other switch.\n" -" Ignored. Exists for compatibility with Windows regedit.\n" -" /? - print this help. Any other switches are ignored.\n" -" /C - create registry from. Not implemented.\n" -"\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"; + "Usage:\n" + " regedit filename\n" + " regedit /E filename [regpath]\n" + " regedit /D regpath\n" + "\n" + "filename - registry file name\n" + "regpath - name of the registry key\n" + "\n" + "When is called without any switches adds contents of the specified\n" + "registry file to the registry\n" + "\n" + "Switches:\n" + " /E - exports contents of the specified registry key to the specified\n" + " 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" + " 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" + " Ignored. Exists for compatibility with Windows regedit.\n" + " /R - location of user.dat file. Can be used with any other switch.\n" + " Ignored. Exists for compatibility with Windows regedit.\n" + " /? - print this help. Any other switches are ignored.\n" + " /C - create registry from. Not implemented.\n" + "\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"; typedef enum { ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE @@ -70,8 +70,7 @@ */ void error_unknown_switch(char chu, char *s) { - if (isalpha(chu)) - { + if (isalpha(chu)) { fprintf(stderr,"%s: Undefined switch /%c!\n", getAppName(), chu); } else { fprintf(stderr,"%s: Alphabetic character is expected after '%c' " @@ -87,8 +86,7 @@ CHAR ch = *s; /* current character */ setAppName("regedit"); - while (ch && ((ch == '-') || (ch == '/'))) - { + while (ch && ((ch == '-') || (ch == '/'))) { char chu; char ch2; @@ -96,14 +94,11 @@ ch = *s; ch2 = *(s+1); chu = toupper(ch); - if (!ch2 || isspace(ch2)) - { - if (chu == 'S' || chu == 'V') - { + if (!ch2 || isspace(ch2)) { + if (chu == 'S' || chu == 'V') { /* ignore these switches */ } else { - switch (chu) - { + switch (chu) { case 'D': action = ACTION_DELETE; break; @@ -121,16 +116,13 @@ } s++; } else { - if (ch2 == ':') - { - switch (chu) - { + if (ch2 == ':') { + switch (chu) { case 'L': /* fall through */ case 'R': s += 2; - while (*s && !isspace(*s)) - { + while (*s && !isspace(*s)) { s++; } break; @@ -146,8 +138,7 @@ } /* skip spaces to the next parameter */ ch = *s; - while (ch && isspace(ch)) - { + while (ch && isspace(ch)) { s++; ch = *s; } @@ -164,75 +155,65 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) { - switch (action) - { - case ACTION_ADD: - { - CHAR filename[MAX_PATH]; - FILE *reg_file; - - get_file_name(&s, filename); - if (!filename[0]) - { - fprintf(stderr,"%s: No file name is specified\n", getAppName()); - fprintf(stderr,usage); - exit(1); - } + switch (action) { + case ACTION_ADD: { + CHAR filename[MAX_PATH]; + FILE *reg_file; - while(filename[0]) - { - reg_file = fopen(filename, "r"); - if (reg_file) - { - processRegLines(reg_file, doSetValue); - } else { - perror(""); - fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename); + get_file_name(&s, filename); + if (!filename[0]) { + fprintf(stderr,"%s: No file name is specified\n", getAppName()); + fprintf(stderr,usage); exit(1); } - get_file_name(&s, filename); - } - break; - } - case ACTION_DELETE: - { - CHAR reg_key_name[KEY_MAX_LEN]; - - get_file_name(&s, reg_key_name); - if (!reg_key_name[0]) - { - fprintf(stderr,"%s: No registry key is specified for removal\n", - getAppName()); - fprintf(stderr,usage); - exit(1); - } - delete_registry_key(reg_key_name); - break; - } - case ACTION_EXPORT: - { - CHAR filename[MAX_PATH]; - - filename[0] = '\0'; - get_file_name(&s, filename); - if (!filename[0]) - { - fprintf(stderr,"%s: No file name is specified\n", getAppName()); - fprintf(stderr,usage); - exit(1); - } - if (s[0]) - { + while(filename[0]) { + reg_file = fopen(filename, "r"); + if (reg_file) { + processRegLines(reg_file, doSetValue); + } else { + perror(""); + fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename); + exit(1); + } + get_file_name(&s, filename); + } + break; + } + case ACTION_DELETE: { CHAR reg_key_name[KEY_MAX_LEN]; get_file_name(&s, reg_key_name); - export_registry_key(filename, reg_key_name); - } else { - export_registry_key(filename, NULL); + if (!reg_key_name[0]) { + fprintf(stderr,"%s: No registry key is specified for removal\n", + getAppName()); + fprintf(stderr,usage); + exit(1); + } + delete_registry_key(reg_key_name); + break; + } + case ACTION_EXPORT: { + CHAR filename[MAX_PATH]; + + filename[0] = '\0'; + get_file_name(&s, filename); + if (!filename[0]) { + fprintf(stderr,"%s: No file name is specified\n", getAppName()); + fprintf(stderr,usage); + exit(1); + } + + if (s[0]) { + CHAR reg_key_name[KEY_MAX_LEN]; + + get_file_name(&s, reg_key_name); + export_registry_key(filename, reg_key_name); + } else { + export_registry_key(filename, NULL); + } + break; } - break; - } default: fprintf(stderr,"%s: Unhandled action!\n", getAppName()); exit(1); Index: programs/regedit/regproc.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/regproc.c,v retrieving revision 1.11 diff -u -r1.11 regproc.c --- programs/regedit/regproc.c 5 Dec 2003 04:42:06 -0000 1.11 +++ programs/regedit/regproc.c 8 Dec 2003 04:56:28 -0000 @@ -46,16 +46,16 @@ static CHAR *app_name = "UNKNOWN"; static CHAR *reg_class_names[] = { - "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT", - "HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER" -}; + "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT", + "HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER" + }; #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_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, + HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER + }; /* return values */ #define NOT_ENOUGH_MEMORY 1 @@ -65,12 +65,12 @@ /* common check of memory allocation results */ #define CHECK_ENOUGH_MEMORY(p) \ - if (!(p)) \ - { \ - fprintf(stderr,"%s: file %s, line %d: Not enough memory", \ - getAppName(), __FILE__, __LINE__); \ - exit(NOT_ENOUGH_MEMORY); \ - } +if (!(p)) \ +{ \ + fprintf(stderr,"%s: file %s, line %d: Not enough memory", \ + getAppName(), __FILE__, __LINE__); \ + exit(NOT_ENOUGH_MEMORY); \ +} /****************************************************************************** * This is a replacement for strsep which is not portable (missing on Solaris). @@ -118,19 +118,15 @@ int pos = 0; /* position of pointer "s" in *command_line */ file_name[0] = 0; - if (!s[0]) - { + if (!s[0]) { return; } - if (s[0] == '"') - { + if (s[0] == '"') { s++; (*command_line)++; - while(s[0] != '"') - { - if (!s[0]) - { + while(s[0] != '"') { + if (!s[0]) { fprintf(stderr,"%s: Unexpected end of file name!\n", getAppName()); exit(1); @@ -139,28 +135,24 @@ pos++; } } else { - while(s[0] && !isspace(s[0])) - { + while(s[0] && !isspace(s[0])) { s++; pos++; } } memcpy(file_name, *command_line, pos * sizeof((*command_line)[0])); /* remove the last backslash */ - if (file_name[pos - 1] == '\\') - { + if (file_name[pos - 1] == '\\') { file_name[pos - 1] = '\0'; } else { file_name[pos] = '\0'; } - if (s[0]) - { + if (s[0]) { s++; pos++; } - while(s[0] && isspace(s[0])) - { + while(s[0] && isspace(s[0])) { s++; pos++; } @@ -173,14 +165,14 @@ */ DWORD convertHexToDWord(char *str, BYTE *buf) { - DWORD dw; - char xbuf[9]; + DWORD dw; + char xbuf[9]; - memcpy(xbuf,str,8); - xbuf[8]='\0'; - sscanf(xbuf,"%08lx",&dw); - memcpy(buf,&dw,sizeof(DWORD)); - return sizeof(DWORD); + memcpy(xbuf,str,8); + xbuf[8]='\0'; + sscanf(xbuf,"%08lx",&dw); + memcpy(buf,&dw,sizeof(DWORD)); + return sizeof(DWORD); } /****************************************************************************** @@ -188,30 +180,29 @@ */ char* convertHexToHexCSV(BYTE *buf, ULONG bufLen) { - char* str; - char* ptrStr; - BYTE* ptrBuf; - - ULONG current = 0; - - str = HeapAlloc(GetProcessHeap(), 0, (bufLen+1)*2); - memset(str, 0, (bufLen+1)*2); - ptrStr = str; /* Pointer to result */ - ptrBuf = buf; /* Pointer to current */ - - while (current < bufLen) - { - BYTE bCur = ptrBuf[current++]; - char res[3]; - - sprintf(res, "%02x", (unsigned int)*&bCur); - strcat(str, res); - strcat(str, ","); - } - - /* Get rid of the last comma */ - str[strlen(str)-1] = '\0'; - return str; + char* str; + char* ptrStr; + BYTE* ptrBuf; + + ULONG current = 0; + + str = HeapAlloc(GetProcessHeap(), 0, (bufLen+1)*2); + memset(str, 0, (bufLen+1)*2); + ptrStr = str; /* Pointer to result */ + ptrBuf = buf; /* Pointer to current */ + + while (current < bufLen) { + BYTE bCur = ptrBuf[current++]; + char res[3]; + + sprintf(res, "%02x", (unsigned int)*&bCur); + strcat(str, res); + strcat(str, ","); + } + + /* Get rid of the last comma */ + str[strlen(str)-1] = '\0'; + return str; } /****************************************************************************** @@ -219,18 +210,18 @@ */ char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen) { - char* str; - DWORD dw; + char* str; + DWORD dw; - if ( bufLen != sizeof(DWORD) ) return NULL; + if ( bufLen != sizeof(DWORD) ) return NULL; - str = HeapAlloc(GetProcessHeap(), 0, (bufLen*2)+1); + str = HeapAlloc(GetProcessHeap(), 0, (bufLen*2)+1); - memcpy(&dw,buf,sizeof(DWORD)); - sprintf(str, "%08lx", dw); + memcpy(&dw,buf,sizeof(DWORD)); + sprintf(str, "%08lx", dw); - /* Get rid of the last comma */ - return str; + /* Get rid of the last comma */ + return str; } /****************************************************************************** @@ -239,42 +230,41 @@ */ DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen) { - char *s = str; /* Pointer to current */ - char *b = buf; /* Pointer to result */ + char *s = str; /* Pointer to current */ + char *b = buf; /* Pointer to result */ + + ULONG strLen = strlen(str); + ULONG strPos = 0; + DWORD byteCount = 0; - ULONG strLen = strlen(str); - ULONG strPos = 0; - DWORD byteCount = 0; - - memset(buf, 0, bufLen); - - /* - * warn the user if we are here with a string longer than 2 bytes that does - * not contains ",". It is more likely because the data is invalid. - */ - if ( ( strLen > 2) && ( strchr(str, ',') == NULL) ) - fprintf(stderr,"%s: WARNING converting CSV hex stream with no comma, " - "input data seems invalid.\n", getAppName()); - if (strLen > 3*bufLen) - fprintf(stderr,"%s: ERROR converting CSV hex stream. Too long\n", - getAppName()); - - while (strPos < strLen) - { - char xbuf[3]; - UINT wc; - - memcpy(xbuf,s,2); xbuf[2]='\0'; - sscanf(xbuf,"%02x",&wc); - if (byteCount < bufLen) - *b++ =(unsigned char)wc; - - s+=3; - strPos+=3; - byteCount++; - } + memset(buf, 0, bufLen); - return byteCount; + /* + * warn the user if we are here with a string longer than 2 bytes that does + * not contains ",". It is more likely because the data is invalid. + */ + if ( ( strLen > 2) && ( strchr(str, ',') == NULL) ) + fprintf(stderr,"%s: WARNING converting CSV hex stream with no comma, " + "input data seems invalid.\n", getAppName()); + if (strLen > 3*bufLen) + fprintf(stderr,"%s: ERROR converting CSV hex stream. Too long\n", + getAppName()); + + while (strPos < strLen) { + char xbuf[3]; + UINT wc; + + memcpy(xbuf,s,2); xbuf[2]='\0'; + sscanf(xbuf,"%02x",&wc); + if (byteCount < bufLen) + *b++ =(unsigned char)wc; + + s+=3; + strPos+=3; + byteCount++; + } + + return byteCount; } /****************************************************************************** @@ -288,22 +278,20 @@ { struct data_type { const char *tag; int len; int type; int parse_type; }; - static const struct data_type data_types[] = - { /* actual type */ /* type to assume for parsing */ - { "\"", 1, REG_SZ, REG_SZ }, - { "str:\"", 5, REG_SZ, REG_SZ }, - { "str(2):\"", 8, REG_EXPAND_SZ, REG_SZ }, - { "hex:", 4, REG_BINARY, REG_BINARY }, - { "dword:", 6, REG_DWORD, REG_DWORD }, - { "hex(", 4, -1, REG_BINARY }, - { NULL, 0, 0, 0 } - }; + static const struct data_type data_types[] = { /* actual type */ /* type to assume for parsing */ + { "\"", 1, REG_SZ, REG_SZ }, + { "str:\"", 5, REG_SZ, REG_SZ }, + { "str(2):\"", 8, REG_EXPAND_SZ, REG_SZ }, + { "hex:", 4, REG_BINARY, REG_BINARY }, + { "dword:", 6, REG_DWORD, REG_DWORD }, + { "hex(", 4, -1, REG_BINARY }, + { NULL, 0, 0, 0 } + }; const struct data_type *ptr; int type; - for (ptr = data_types; ptr->tag; ptr++) - { + for (ptr = data_types; ptr->tag; ptr++) { if (memcmp( ptr->tag, *lpValue, ptr->len )) continue; @@ -332,24 +320,24 @@ */ LPSTR getArg( LPSTR arg) { - LPSTR tmp = NULL; - ULONG len; + LPSTR tmp = NULL; + ULONG len; - if (arg == NULL) - return NULL; + if (arg == NULL) + return NULL; - /* - * Get rid of surrounding quotes - */ - len = strlen(arg); + /* + * Get rid of surrounding quotes + */ + len = strlen(arg); - if( arg[len-1] == '\"' ) arg[len-1] = '\0'; - if( arg[0] == '\"' ) arg++; + if( arg[len-1] == '\"' ) arg[len-1] = '\0'; + if( arg[0] == '\"' ) arg++; - tmp = HeapAlloc(GetProcessHeap(), 0, strlen(arg)+1); - strcpy(tmp, arg); + tmp = HeapAlloc(GetProcessHeap(), 0, strlen(arg)+1); + strcpy(tmp, arg); - return tmp; + return tmp; } /****************************************************************************** @@ -360,13 +348,10 @@ int str_idx = 0; /* current character under analysis */ int val_idx = 0; /* the last character of the unescaped string */ int len = strlen(str); - for (str_idx = 0; str_idx < len; str_idx++, val_idx++) - { - if (str[str_idx] == '\\') - { + for (str_idx = 0; str_idx < len; str_idx++, val_idx++) { + if (str[str_idx] == '\\') { str_idx++; - switch (str[str_idx]) - { + switch (str[str_idx]) { case 'n': str[val_idx] = '\n'; break; @@ -397,64 +382,59 @@ */ HRESULT setValue(LPSTR val_name, LPSTR val_data) { - HRESULT hRes; - DWORD dwDataType, dwParseType; - LPBYTE lpbData; - BYTE convert[KEY_MAX_LEN]; - BYTE *bBigBuffer = 0; - DWORD dwLen; - - if ( (val_name == NULL) || (val_data == NULL) ) - return ERROR_INVALID_PARAMETER; - - /* Get the data type stored into the value field */ - dwDataType = getDataType(&val_data, &dwParseType); - - if ( dwParseType == REG_SZ) /* no conversion for string */ - { - dwLen = strlen(val_data); - if (dwLen>0 && val_data[dwLen-1]=='"') - { - dwLen--; - val_data[dwLen]='\0'; - } - dwLen++; - REGPROC_unescape_string(val_data); - lpbData = val_data; - } - else if (dwParseType == REG_DWORD) /* Convert the dword types */ - { - dwLen = convertHexToDWord(val_data, convert); - lpbData = convert; - } - else /* Convert the hexadecimal types */ - { - int b_len = strlen (val_data)+2/3; - if (b_len > KEY_MAX_LEN) - { - bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len); - CHECK_ENOUGH_MEMORY(bBigBuffer); - dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len); - lpbData = bBigBuffer; - } - else + HRESULT hRes; + DWORD dwDataType, dwParseType; + LPBYTE lpbData; + BYTE convert[KEY_MAX_LEN]; + BYTE *bBigBuffer = 0; + DWORD dwLen; + + if ( (val_name == NULL) || (val_data == NULL) ) + return ERROR_INVALID_PARAMETER; + + /* Get the data type stored into the value field */ + dwDataType = getDataType(&val_data, &dwParseType); + + if ( dwParseType == REG_SZ) /* no conversion for string */ { - dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN); - lpbData = convert; + dwLen = strlen(val_data); + if (dwLen>0 && val_data[dwLen-1]=='"') + { + dwLen--; + val_data[dwLen]='\0'; + } + dwLen++; + REGPROC_unescape_string(val_data); + lpbData = val_data; + } else if (dwParseType == REG_DWORD) /* Convert the dword types */ + { + dwLen = convertHexToDWord(val_data, convert); + lpbData = convert; + } else /* Convert the hexadecimal types */ + { + int b_len = strlen (val_data)+2/3; + if (b_len > KEY_MAX_LEN) { + bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len); + CHECK_ENOUGH_MEMORY(bBigBuffer); + dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len); + lpbData = bBigBuffer; + } else { + dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN); + lpbData = convert; + } } - } - hRes = RegSetValueEx( - currentKeyHandle, - val_name, - 0, /* Reserved */ - dwDataType, - lpbData, - dwLen); - - if (bBigBuffer) - HeapFree (GetProcessHeap(), 0, bBigBuffer); - return hRes; + hRes = RegSetValueEx( + currentKeyHandle, + val_name, + 0, /* Reserved */ + dwDataType, + lpbData, + dwLen); + + if (bBigBuffer) + HeapFree (GetProcessHeap(), 0, bBigBuffer); + return hRes; } @@ -463,39 +443,39 @@ */ HRESULT openKey( LPSTR stdInput) { - DWORD dwDisp; - HRESULT hRes; + DWORD dwDisp; + HRESULT hRes; - /* Sanity checks */ - if (stdInput == NULL) - return ERROR_INVALID_PARAMETER; - - /* Get the registry class */ - currentKeyClass = getRegClass(stdInput); /* Sets global variable */ - if (currentKeyClass == (HKEY)ERROR_INVALID_PARAMETER) - return (HRESULT)ERROR_INVALID_PARAMETER; - - /* Get the key name */ - currentKeyName = getRegKeyName(stdInput); /* Sets global variable */ - if (currentKeyName == NULL) - return ERROR_INVALID_PARAMETER; - - hRes = RegCreateKeyEx( - currentKeyClass, /* Class */ - currentKeyName, /* Sub Key */ - 0, /* MUST BE 0 */ - NULL, /* object type */ - REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */ - KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */ - NULL, /* security attribute */ - ¤tKeyHandle, /* result */ - &dwDisp); /* disposition, REG_CREATED_NEW_KEY or - REG_OPENED_EXISTING_KEY */ + /* Sanity checks */ + if (stdInput == NULL) + return ERROR_INVALID_PARAMETER; + + /* Get the registry class */ + currentKeyClass = getRegClass(stdInput); /* Sets global variable */ + if (currentKeyClass == (HKEY)ERROR_INVALID_PARAMETER) + return (HRESULT)ERROR_INVALID_PARAMETER; + + /* Get the key name */ + currentKeyName = getRegKeyName(stdInput); /* Sets global variable */ + if (currentKeyName == NULL) + return ERROR_INVALID_PARAMETER; + + hRes = RegCreateKeyEx( + currentKeyClass, /* Class */ + currentKeyName, /* Sub Key */ + 0, /* MUST BE 0 */ + NULL, /* object type */ + REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */ + KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */ + NULL, /* security attribute */ + ¤tKeyHandle, /* result */ + &dwDisp); /* disposition, REG_CREATED_NEW_KEY or + REG_OPENED_EXISTING_KEY */ - if (hRes == ERROR_SUCCESS) - bTheKeyIsOpen = TRUE; + if (hRes == ERROR_SUCCESS) + bTheKeyIsOpen = TRUE; - return hRes; + return hRes; } @@ -505,32 +485,30 @@ */ LPSTR getRegKeyName(LPSTR lpLine) { - LPSTR keyNameBeg; - char lpLineCopy[KEY_MAX_LEN]; + LPSTR keyNameBeg; + char lpLineCopy[KEY_MAX_LEN]; - if (lpLine == NULL) - return NULL; + if (lpLine == NULL) + return NULL; - strcpy(lpLineCopy, lpLine); + strcpy(lpLineCopy, lpLine); - keyNameBeg = strchr(lpLineCopy, '\\'); /* The key name start by '\' */ - if (keyNameBeg) - { - LPSTR keyNameEnd; - - keyNameBeg++; /* is not part of the name */ - keyNameEnd = strchr(lpLineCopy, ']'); - if (keyNameEnd) - { - *keyNameEnd = '\0'; /* remove ']' from the key name */ - } - } else { - keyNameBeg = lpLineCopy + strlen(lpLineCopy); /* branch - empty string */ - } - currentKeyName = HeapAlloc(GetProcessHeap(), 0, strlen(keyNameBeg) + 1); - CHECK_ENOUGH_MEMORY(currentKeyName); - strcpy(currentKeyName, keyNameBeg); - return currentKeyName; + keyNameBeg = strchr(lpLineCopy, '\\'); /* The key name start by '\' */ + if (keyNameBeg) { + LPSTR keyNameEnd; + + keyNameBeg++; /* is not part of the name */ + keyNameEnd = strchr(lpLineCopy, ']'); + if (keyNameEnd) { + *keyNameEnd = '\0'; /* remove ']' from the key name */ + } + } else { + keyNameBeg = lpLineCopy + strlen(lpLineCopy); /* branch - empty string */ + } + currentKeyName = HeapAlloc(GetProcessHeap(), 0, strlen(keyNameBeg) + 1); + CHECK_ENOUGH_MEMORY(currentKeyName); + strcpy(currentKeyName, keyNameBeg); + return currentKeyName; } /****************************************************************************** @@ -539,42 +517,39 @@ */ HKEY getRegClass(LPSTR lpClass) { - LPSTR classNameEnd; - LPSTR classNameBeg; - int i; + LPSTR classNameEnd; + LPSTR classNameBeg; + int i; - char lpClassCopy[KEY_MAX_LEN]; + char lpClassCopy[KEY_MAX_LEN]; - if (lpClass == NULL) - return (HKEY)ERROR_INVALID_PARAMETER; + if (lpClass == NULL) + return (HKEY)ERROR_INVALID_PARAMETER; - strncpy(lpClassCopy, lpClass, KEY_MAX_LEN); + strncpy(lpClassCopy, lpClass, KEY_MAX_LEN); - classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */ - if (!classNameEnd) /* or the whole string */ - { - classNameEnd = lpClassCopy + strlen(lpClassCopy); - if (classNameEnd[-1] == ']') - { - classNameEnd--; - } - } - *classNameEnd = '\0'; /* Isolate the class name */ - if (lpClassCopy[0] == '[') - { - classNameBeg = lpClassCopy + 1; - } else { - classNameBeg = lpClassCopy; - } - - for (i = 0; i < REG_CLASS_NUMBER; i++) - { - if (!strcmp(classNameBeg, reg_class_names[i])) - { - return reg_class_keys[i]; - } - } - return (HKEY)ERROR_INVALID_PARAMETER; + classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */ + if (!classNameEnd) /* or the whole string */ + { + classNameEnd = lpClassCopy + strlen(lpClassCopy); + if (classNameEnd[-1] == ']') + { + classNameEnd--; + } + } + *classNameEnd = '\0'; /* Isolate the class name */ + if (lpClassCopy[0] == '[') { + classNameBeg = lpClassCopy + 1; + } else { + classNameBeg = lpClassCopy; + } + + for (i = 0; i < REG_CLASS_NUMBER; i++) { + if (!strcmp(classNameBeg, reg_class_names[i])) { + return reg_class_keys[i]; + } + } + return (HKEY)ERROR_INVALID_PARAMETER; } /****************************************************************************** @@ -582,15 +557,15 @@ */ void closeKey() { - RegCloseKey(currentKeyHandle); + RegCloseKey(currentKeyHandle); - HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */ + HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */ - bTheKeyIsOpen = FALSE; + bTheKeyIsOpen = FALSE; - currentKeyName = NULL; - currentKeyClass = 0; - currentKeyHandle = 0; + currentKeyName = NULL; + currentKeyClass = 0; + currentKeyHandle = 0; } /****************************************************************************** @@ -600,38 +575,35 @@ */ void doSetValue(LPSTR stdInput) { - /* - * We encoutered the end of the file, make sure we - * close the opened key and exit - */ - if (stdInput == NULL) - { - if (bTheKeyIsOpen != FALSE) - closeKey(); - - return; - } - - if ( stdInput[0] == '[') /* We are reading a new key */ - { - if ( bTheKeyIsOpen != FALSE ) - closeKey(); /* Close the previous key before */ - - if ( openKey(stdInput) != ERROR_SUCCESS ) - fprintf(stderr,"%s: setValue failed to open key %s\n", - getAppName(), stdInput); - } - else if( ( bTheKeyIsOpen ) && - (( stdInput[0] == '@') || /* reading a default @=data pair */ - ( stdInput[0] == '\"'))) /* reading a new value=data pair */ - { - processSetValue(stdInput); - } - else /* since we are assuming that the */ - { /* file format is valid we must */ - if ( bTheKeyIsOpen ) /* be reading a blank line which */ - closeKey(); /* indicate end of this key processing */ - } + /* + * We encoutered the end of the file, make sure we + * close the opened key and exit + */ + if (stdInput == NULL) { + if (bTheKeyIsOpen != FALSE) + closeKey(); + + return; + } + + if ( stdInput[0] == '[') /* We are reading a new key */ + { + if ( bTheKeyIsOpen != FALSE ) + closeKey(); /* Close the previous key before */ + + if ( openKey(stdInput) != ERROR_SUCCESS ) + fprintf(stderr,"%s: setValue failed to open key %s\n", + getAppName(), stdInput); + } else if( ( bTheKeyIsOpen ) && + (( stdInput[0] == '@') || /* reading a default @=data pair */ + ( stdInput[0] == '\"'))) /* reading a new value=data pair */ + { + processSetValue(stdInput); + } else /* since we are assuming that the */ + { /* file format is valid we must */ + if ( bTheKeyIsOpen ) /* be reading a blank line which */ + closeKey(); /* indicate end of this key processing */ + } } /****************************************************************************** @@ -639,39 +611,37 @@ * 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 - * close the opened key and exit - */ - if (stdInput == NULL) - { - if (bTheKeyIsOpen != FALSE) - closeKey(); - - return; - } - - if ( stdInput[0] == '[') /* We are reading a new key */ - { - if ( bTheKeyIsOpen != FALSE ) - closeKey(); /* Close the previous key before */ - - if ( openKey(stdInput) != ERROR_SUCCESS ) - fprintf(stderr,"%s: queryValue failed to open key %s\n", - getAppName(), stdInput); - } - else if( ( bTheKeyIsOpen ) && - (( stdInput[0] == '@') || /* reading a default @=data pair */ - ( stdInput[0] == '\"'))) /* reading a new value=data pair */ - { - processQueryValue(stdInput); - } - else /* since we are assuming that the */ - { /* file format is valid we must */ - if ( bTheKeyIsOpen ) /* be reading a blank line which */ - closeKey(); /* indicate end of this key processing */ - } +void doQueryValue(LPSTR stdInput) +{ + /* + * We encoutered the end of the file, make sure we + * close the opened key and exit + */ + if (stdInput == NULL) { + if (bTheKeyIsOpen != FALSE) + closeKey(); + + return; + } + + if ( stdInput[0] == '[') /* We are reading a new key */ + { + if ( bTheKeyIsOpen != FALSE ) + closeKey(); /* Close the previous key before */ + + if ( openKey(stdInput) != ERROR_SUCCESS ) + fprintf(stderr,"%s: queryValue failed to open key %s\n", + getAppName(), stdInput); + } else if( ( bTheKeyIsOpen ) && + (( stdInput[0] == '@') || /* reading a default @=data pair */ + ( stdInput[0] == '\"'))) /* reading a new value=data pair */ + { + processQueryValue(stdInput); + } else /* since we are assuming that the */ + { /* file format is valid we must */ + if ( bTheKeyIsOpen ) /* be reading a blank line which */ + closeKey(); /* indicate end of this key processing */ + } } /****************************************************************************** @@ -679,8 +649,9 @@ * receives the currently read line and dispatch the work depending on the * context. */ -void doDeleteValue(LPSTR line) { - fprintf(stderr,"%s: deleteValue not yet implemented\n", getAppName()); +void doDeleteValue(LPSTR line) +{ + fprintf(stderr,"%s: deleteValue not yet implemented\n", getAppName()); } /****************************************************************************** @@ -688,8 +659,9 @@ * receives the currently read line and dispatch the work depending on the * context. */ -void doDeleteKey(LPSTR line) { - fprintf(stderr,"%s: deleteKey not yet implemented\n", getAppName()); +void doDeleteKey(LPSTR line) +{ + fprintf(stderr,"%s: deleteKey not yet implemented\n", getAppName()); } /****************************************************************************** @@ -697,8 +669,9 @@ * receives the currently read line and dispatch the work depending on the * context. */ -void doCreateKey(LPSTR line) { - fprintf(stderr,"%s: createKey not yet implemented\n", getAppName()); +void doCreateKey(LPSTR line) +{ + fprintf(stderr,"%s: createKey not yet implemented\n", getAppName()); } /****************************************************************************** @@ -711,63 +684,55 @@ */ void processSetValue(LPSTR line) { - LPSTR val_name; /* registry value name */ - LPSTR val_data; /* registry value data */ + LPSTR val_name; /* registry value name */ + LPSTR val_data; /* registry value data */ + + int line_idx = 0; /* current character under analysis */ + HRESULT hRes = 0; + + /* get value name */ + if (line[line_idx] == '@' && line[line_idx + 1] == '=') { + line[line_idx] = '\0'; + val_name = line; + line_idx++; + } else if (line[line_idx] == '\"') { + line_idx++; + val_name = line + line_idx; + while (TRUE) { + if (line[line_idx] == '\\') /* skip escaped character */ + { + line_idx += 2; + } else { + if (line[line_idx] == '\"') { + line[line_idx] = '\0'; + line_idx++; + break; + } else { + line_idx++; + } + } + } + if (line[line_idx] != '=') { + line[line_idx] = '\"'; + fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); + return; + } - int line_idx = 0; /* current character under analysis */ - HRESULT hRes = 0; + } else { + fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); + return; + } + line_idx++; /* skip the '=' character */ + val_data = line + line_idx; - /* get value name */ - if (line[line_idx] == '@' && line[line_idx + 1] == '=') - { - line[line_idx] = '\0'; - val_name = line; - line_idx++; - } - else if (line[line_idx] == '\"') - { - line_idx++; - val_name = line + line_idx; - while (TRUE) - { - if (line[line_idx] == '\\') /* skip escaped character */ - { - line_idx += 2; - } else { - if (line[line_idx] == '\"') - { - line[line_idx] = '\0'; - line_idx++; - break; - } else { - line_idx++; - } - } - } - if (line[line_idx] != '=') - { - line[line_idx] = '\"'; - fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); - return; - } - - } - else - { - fprintf(stderr,"Warning! unrecognized line:\n%s\n", line); - return; - } - line_idx++; /* skip the '=' character */ - val_data = line + line_idx; - - REGPROC_unescape_string(val_name); - hRes = setValue(val_name, val_data); - if ( hRes != ERROR_SUCCESS ) - fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n", - getAppName(), - currentKeyName, - val_name, - val_data); + REGPROC_unescape_string(val_name); + hRes = setValue(val_name, val_data); + if ( hRes != ERROR_SUCCESS ) + fprintf(stderr,"%s: ERROR Key %s not created. Value: %s, Data: %s\n", + getAppName(), + currentKeyName, + val_name, + val_data); } /****************************************************************************** @@ -776,138 +741,128 @@ */ void processQueryValue(LPSTR cmdline) { - fprintf(stderr,"ERROR!!! - temporary disabled"); - exit(1); + fprintf(stderr,"ERROR!!! - temporary disabled"); + exit(1); #if 0 - LPSTR argv[QUERY_VALUE_MAX_ARGS];/* args storage */ - LPSTR token = NULL; /* current token analyzed */ - ULONG argCounter = 0; /* counter of args */ - INT counter; - HRESULT hRes = 0; - LPSTR keyValue = NULL; - LPSTR lpsRes = NULL; - - /* - * Init storage and parse the line - */ - for (counter=0; counter<QUERY_VALUE_MAX_ARGS; counter++) - argv[counter]=NULL; - - while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) - { - argv[argCounter++] = getArg(token); - - if (argCounter == QUERY_VALUE_MAX_ARGS) - break; /* Stop processing args no matter what */ - } - - /* The value we look for is the first token on the line */ - if ( argv[0] == NULL ) - return; /* SHOULD NOT HAPPEN */ - else - keyValue = argv[0]; - - if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) - { - LONG lLen = KEY_MAX_LEN; - CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); - /* - * We need to query the key default value - */ - hRes = RegQueryValue( - currentKeyHandle, - currentKeyName, - (LPBYTE)lpsData, - &lLen); - - if (hRes==ERROR_MORE_DATA) { - lpsData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsData,lLen); - hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen); - } + LPSTR argv[QUERY_VALUE_MAX_ARGS];/* args storage */ + LPSTR token = NULL; /* current token analyzed */ + ULONG argCounter = 0; /* counter of args */ + INT counter; + HRESULT hRes = 0; + LPSTR keyValue = NULL; + LPSTR lpsRes = NULL; - if (hRes == ERROR_SUCCESS) - { - lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen); - strncpy(lpsRes, lpsData, lLen); - lpsRes[lLen-1]='\0'; - } - } - else - { - DWORD dwLen = KEY_MAX_LEN; - BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); - DWORD dwType; /* - * We need to query a specific value for the key + * Init storage and parse the line */ - hRes = RegQueryValueEx( - currentKeyHandle, - keyValue, - 0, - &dwType, - (LPBYTE)lpbData, - &dwLen); - - if (hRes==ERROR_MORE_DATA) { - lpbData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpbData,dwLen); - hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen); + for (counter=0; counter<QUERY_VALUE_MAX_ARGS; counter++) + argv[counter]=NULL; + + while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) { + argv[argCounter++] = getArg(token); + + if (argCounter == QUERY_VALUE_MAX_ARGS) + break; /* Stop processing args no matter what */ } - if (hRes == ERROR_SUCCESS) - { - /* - * Convert the returned data to a displayable format - */ - switch ( dwType ) - { - case REG_SZ: - case REG_EXPAND_SZ: - { - lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen); - strncpy(lpsRes, lpbData, dwLen); - lpsRes[dwLen-1]='\0'; - break; + /* The value we look for is the first token on the line */ + if ( argv[0] == NULL ) + return; /* SHOULD NOT HAPPEN */ + else + keyValue = argv[0]; + + if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) { + LONG lLen = KEY_MAX_LEN; + CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); + /* + * We need to query the key default value + */ + hRes = RegQueryValue( + currentKeyHandle, + currentKeyName, + (LPBYTE)lpsData, + &lLen); + + if (hRes==ERROR_MORE_DATA) { + lpsData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsData,lLen); + hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen); } - case REG_DWORD: - { - lpsRes = convertHexToDWORDStr(lpbData, dwLen); - break; + + if (hRes == ERROR_SUCCESS) { + lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen); + strncpy(lpsRes, lpsData, lLen); + lpsRes[lLen-1]='\0'; } - default: - { - lpsRes = convertHexToHexCSV(lpbData, dwLen); - break; + } else { + DWORD dwLen = KEY_MAX_LEN; + BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN); + DWORD dwType; + /* + * We need to query a specific value for the key + */ + hRes = RegQueryValueEx( + currentKeyHandle, + keyValue, + 0, + &dwType, + (LPBYTE)lpbData, + &dwLen); + + if (hRes==ERROR_MORE_DATA) { + lpbData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpbData,dwLen); + hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen); + } + + if (hRes == ERROR_SUCCESS) { + /* + * Convert the returned data to a displayable format + */ + switch ( dwType ) { + case REG_SZ: + case REG_EXPAND_SZ: { + lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen); + strncpy(lpsRes, lpbData, dwLen); + lpsRes[dwLen-1]='\0'; + break; + } + case REG_DWORD: { + lpsRes = convertHexToDWORDStr(lpbData, dwLen); + break; + } + default: { + lpsRes = convertHexToHexCSV(lpbData, dwLen); + break; + } + } } - } + + HeapFree(GetProcessHeap(), 0, lpbData); } - HeapFree(GetProcessHeap(), 0, lpbData); - } + if ( hRes == ERROR_SUCCESS ) + fprintf(stderr, + "%s: Value \"%s\" = \"%s\" in key [%s]\n", + getAppName(), + keyValue, + lpsRes, + currentKeyName); + + else + fprintf(stderr,"%s: ERROR Value \"%s\" not found for key \"%s\".\n", + getAppName(), + keyValue, + currentKeyName); - if ( hRes == ERROR_SUCCESS ) - fprintf(stderr, - "%s: Value \"%s\" = \"%s\" in key [%s]\n", - getAppName(), - keyValue, - lpsRes, - currentKeyName); - - else - fprintf(stderr,"%s: ERROR Value \"%s\" not found for key \"%s\".\n", - getAppName(), - keyValue, - currentKeyName); - - /* - * Do some cleanup - */ - for (counter=0; counter<argCounter; counter++) - if (argv[counter] != NULL) - HeapFree(GetProcessHeap(), 0, argv[counter]); + /* + * Do some cleanup + */ + for (counter=0; counter<argCounter; counter++) + if (argv[counter] != NULL) + HeapFree(GetProcessHeap(), 0, argv[counter]); - if (lpsRes != NULL) - HeapFree(GetProcessHeap(), 0, lpsRes); + if (lpsRes != NULL) + HeapFree(GetProcessHeap(), 0, lpsRes); #endif } @@ -927,12 +882,10 @@ line = HeapAlloc(GetProcessHeap(), 0, lineSize); CHECK_ENOUGH_MEMORY(line); - while (!feof(in)) - { + while (!feof(in)) { LPSTR s; /* The pointer into line for where the current fgets should read */ s = line; - for (;;) - { + for (;;) { size_t size_remaining; int size_to_get; char *s_eol; /* various local uses */ @@ -959,15 +912,11 @@ * eof, error, eol or getting the maximum amount. Abort on error. */ size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining); - if (NULL == fgets (s, size_to_get, in)) - { - if (ferror(in)) - { + if (NULL == fgets (s, size_to_get, in)) { + if (ferror(in)) { perror ("While reading input"); exit (IO_ERROR); - } - else - { + } else { assert (feof(in)); *s = '\0'; /* It is not clear to me from the definition that the @@ -979,40 +928,35 @@ /* If we didn't read the eol nor the eof go around for the rest */ s_eol = strchr (s, '\n'); - if (!feof (in) && !s_eol) - { + if (!feof (in) && !s_eol) { s = strchr (s, '\0'); /* It should be s + size_to_get - 1 but this is safer */ continue; } /* If it is a comment line then discard it and go around again */ - if (line [0] == '#') - { + if (line [0] == '#') { s = line; continue; } /* Remove any line feed. Leave s_eol on the \0 */ - if (s_eol) - { + if (s_eol) { *s_eol = '\0'; if (s_eol > line && *(s_eol-1) == '\r') *--s_eol = '\0'; - } - else + } else s_eol = strchr (s, '\0'); /* If there is a concatenating \\ then go around again */ - if (s_eol > line && *(s_eol-1) == '\\') - { + if (s_eol > line && *(s_eol-1) == '\\') { int c; s = s_eol-1; /* The following error protection could be made more self- * correcting but I thought it not worth trying. */ if ((c = fgetc (in)) == EOF || c != ' ' || - (c = fgetc (in)) == EOF || c != ' ') + (c = fgetc (in)) == EOF || c != ' ') fprintf(stderr,"%s: ERROR - invalid continuation.\n", getAppName()); continue; @@ -1032,70 +976,66 @@ * This funtion 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) { - HMODULE theLib = 0; - UINT retVal = 0; - - /* Check for valid input */ - if (stdInput == NULL) - return; - - /* Load and register the library, then free it */ - theLib = LoadLibrary(stdInput); - if (theLib) - { - FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer"); - if (lpfnDLLRegProc) - retVal = (*lpfnDLLRegProc)(); - else - fprintf(stderr,"%s: Couldn't find DllRegisterServer proc in '%s'.\n", - getAppName(), stdInput); +void doRegisterDLL(LPSTR stdInput) +{ + HMODULE theLib = 0; + UINT retVal = 0; + + /* Check for valid input */ + if (stdInput == NULL) + return; - if (retVal != S_OK) - fprintf(stderr,"%s: DLLRegisterServer error 0x%x in '%s'.\n", - getAppName(), retVal, stdInput); - - FreeLibrary(theLib); - } - else - { - fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput); - } + /* Load and register the library, then free it */ + theLib = LoadLibrary(stdInput); + if (theLib) { + FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer"); + if (lpfnDLLRegProc) + retVal = (*lpfnDLLRegProc)(); + else + fprintf(stderr,"%s: Couldn't find DllRegisterServer proc in '%s'.\n", + getAppName(), stdInput); + + if (retVal != S_OK) + fprintf(stderr,"%s: DLLRegisterServer error 0x%x in '%s'.\n", + getAppName(), retVal, stdInput); + + FreeLibrary(theLib); + } else { + fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput); + } } /****************************************************************************** * This funtion 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) { - HMODULE theLib = 0; - UINT retVal = 0; - - /* Check for valid input */ - if (stdInput == NULL) - return; - - /* Load and unregister the library, then free it */ - theLib = LoadLibrary(stdInput); - if (theLib) - { - FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer"); - if (lpfnDLLRegProc) - retVal = (*lpfnDLLRegProc)(); - else - fprintf(stderr,"%s: Couldn't find DllUnregisterServer proc in '%s'.\n", - getAppName(), stdInput); +void doUnregisterDLL(LPSTR stdInput) +{ + HMODULE theLib = 0; + UINT retVal = 0; + + /* Check for valid input */ + if (stdInput == NULL) + return; + + /* Load and unregister the library, then free it */ + theLib = LoadLibrary(stdInput); + if (theLib) { + FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer"); + if (lpfnDLLRegProc) + retVal = (*lpfnDLLRegProc)(); + else + fprintf(stderr,"%s: Couldn't find DllUnregisterServer proc in '%s'.\n", + getAppName(), stdInput); + + if (retVal != S_OK) + fprintf(stderr,"%s: DLLUnregisterServer error 0x%x in '%s'.\n", + getAppName(), retVal, stdInput); - if (retVal != S_OK) - fprintf(stderr,"%s: DLLUnregisterServer error 0x%x in '%s'.\n", - getAppName(), retVal, stdInput); - - FreeLibrary(theLib); - } - else - { - fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput); - } + FreeLibrary(theLib); + } else { + fprintf(stderr,"%s: Could not load DLL '%s'.\n", getAppName(), stdInput); + } } /**************************************************************************** @@ -1104,7 +1044,8 @@ * Print the message for GetLastError */ -void REGPROC_print_error() { +void REGPROC_print_error() +{ LPVOID lpMsgBuf; DWORD error_code; int status; @@ -1135,12 +1076,11 @@ void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD required_len) { required_len++; - if (required_len > *len) - { + if (required_len > *len) { *len = required_len; if (!*buffer) *buffer = HeapAlloc(GetProcessHeap(), 0, *len * sizeof(**buffer)); - else + else *buffer = HeapReAlloc(GetProcessHeap(), 0, *buffer, *len * sizeof(**buffer)); CHECK_ENOUGH_MEMORY(*buffer); } @@ -1155,11 +1095,9 @@ size_t i; /* escaping characters */ - for (i = 0; i < len; i++) - { + for (i = 0; i < len; i++) { CHAR c = str[i]; - switch (c) - { + switch (c) { case '\\': fputs("\\\\", file); break; @@ -1209,8 +1147,7 @@ if (RegQueryInfoKey(key, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL, NULL, &max_val_name_len, &max_val_size, NULL, NULL - ) != ERROR_SUCCESS) - { + ) != ERROR_SUCCESS) { REGPROC_print_error(); } curr_len = strlen(*reg_key_name_buf); @@ -1218,10 +1155,9 @@ max_sub_key_len + curr_len + 1); REGPROC_resize_char_buffer(val_name_buf, val_name_len, max_val_name_len); - if (max_val_size > *val_size) - { + if (max_val_size > *val_size) { *val_size = max_val_size; - if (!*val_buf) *val_buf = HeapAlloc(GetProcessHeap(), 0, *val_size); + if (!*val_buf) *val_buf = HeapAlloc(GetProcessHeap(), 0, *val_size); else *val_buf = HeapReAlloc(GetProcessHeap(), 0, *val_buf, *val_size); CHECK_ENOUGH_MEMORY(val_buf); } @@ -1233,25 +1169,21 @@ /* print all the values */ i = 0; more_data = TRUE; - while(more_data) - { + while(more_data) { DWORD value_type; DWORD val_name_len1 = *val_name_len; DWORD val_size1 = *val_size; ret = RegEnumValue(key, i, *val_name_buf, &val_name_len1, NULL, &value_type, *val_buf, &val_size1); - if (ret != ERROR_SUCCESS) - { + if (ret != ERROR_SUCCESS) { more_data = FALSE; - if (ret != ERROR_NO_MORE_ITEMS) - { + if (ret != ERROR_NO_MORE_ITEMS) { REGPROC_print_error(); } } else { i++; - if ((*val_name_buf)[0]) - { + if ((*val_name_buf)[0]) { fputs("\"", file); REGPROC_export_string(file, *val_name_buf); fputs("\"=", file); @@ -1259,8 +1191,7 @@ fputs("@=", file); } - switch (value_type) - { + switch (value_type) { case REG_SZ: case REG_EXPAND_SZ: fputs("\"", file); @@ -1274,53 +1205,48 @@ default: fprintf(stderr,"%s: warning - unsupported registry format '%ld', " - "treat as binary\n", - getAppName(), value_type); + "treat as binary\n", + getAppName(), value_type); fprintf(stderr,"key name: \"%s\"\n", *reg_key_name_buf); fprintf(stderr,"value name:\"%s\"\n\n", *val_name_buf); /* falls through */ case REG_MULTI_SZ: /* falls through */ - case REG_BINARY: - { - DWORD i1; - CHAR *hex_prefix; - CHAR buf[20]; - int cur_pos; - - if (value_type == REG_BINARY) - { - hex_prefix = "hex:"; - } else { - hex_prefix = buf; - sprintf(buf, "hex(%ld):", value_type); - } - - /* position of where the next character will be printed */ - /* NOTE: yes, strlen("hex:") is used even for hex(x): */ - cur_pos = strlen("\"\"=") + strlen("hex:") + - strlen(*val_name_buf); - - fputs(hex_prefix, file); - for (i1 = 0; i1 < val_size1; i1++) - { - fprintf(file, "%02x", (unsigned int)(*val_buf)[i1]); - if (i1 + 1 < val_size1) - { - fputs(",", file); + case REG_BINARY: { + DWORD i1; + CHAR *hex_prefix; + CHAR buf[20]; + int cur_pos; + + if (value_type == REG_BINARY) { + hex_prefix = "hex:"; + } else { + hex_prefix = buf; + sprintf(buf, "hex(%ld):", value_type); } - cur_pos += 3; - /* wrap the line */ - if (cur_pos > REG_FILE_HEX_LINE_LEN) - { - fputs("\\\n ", file); - cur_pos = 2; + /* position of where the next character will be printed */ + /* NOTE: yes, strlen("hex:") is used even for hex(x): */ + cur_pos = strlen("\"\"=") + strlen("hex:") + + strlen(*val_name_buf); + + fputs(hex_prefix, file); + for (i1 = 0; i1 < val_size1; i1++) { + fprintf(file, "%02x", (unsigned int)(*val_buf)[i1]); + if (i1 + 1 < val_size1) { + fputs(",", file); + } + cur_pos += 3; + + /* wrap the line */ + if (cur_pos > REG_FILE_HEX_LINE_LEN) { + fputs("\\\n ", file); + cur_pos = 2; + } } + fputs("\n", file); + break; } - fputs("\n", file); - break; - } } } } @@ -1328,17 +1254,14 @@ i = 0; more_data = TRUE; (*reg_key_name_buf)[curr_len] = '\\'; - while(more_data) - { + while(more_data) { DWORD buf_len = *reg_key_name_len - curr_len; 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) - { + if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) { more_data = FALSE; - if (ret != ERROR_NO_MORE_ITEMS) - { + if (ret != ERROR_NO_MORE_ITEMS) { REGPROC_print_error(); } } else { @@ -1346,8 +1269,7 @@ i++; if (RegOpenKey(key, *reg_key_name_buf + curr_len + 1, - &subkey) == ERROR_SUCCESS) - { + &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); @@ -1365,8 +1287,7 @@ FILE *REGPROC_open_export_file(CHAR *file_name) { FILE *file = fopen(file_name, "w"); - if (!file) - { + if (!file) { perror(""); fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), file_name); exit(1); @@ -1402,8 +1323,7 @@ val_buf = HeapAlloc(GetProcessHeap(), 0, val_size); CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf); - if (reg_key_name && reg_key_name[0]) - { + if (reg_key_name && reg_key_name[0]) { CHAR *branch_name; HKEY key; @@ -1413,25 +1333,21 @@ /* open the specified key */ reg_key_class = getRegClass(reg_key_name); - if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) - { + if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) { fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", getAppName(), reg_key_name); exit(1); } branch_name = getRegKeyName(reg_key_name); CHECK_ENOUGH_MEMORY(branch_name); - if (!branch_name[0]) - { + if (!branch_name[0]) { /* no branch - registry class is specified */ file = REGPROC_open_export_file(file_name); export_hkey(file, reg_key_class, ®_key_name_buf, ®_key_name_len, &val_name_buf, &val_name_len, &val_buf, &val_size); - } - else if (RegOpenKey(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, @@ -1449,13 +1365,11 @@ /* export all registry classes */ file = REGPROC_open_export_file(file_name); - for (i = 0; i < REG_CLASS_NUMBER; i++) - { + for (i = 0; i < REG_CLASS_NUMBER; i++) { /* 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_USER && + reg_class_keys[i] != HKEY_CURRENT_CONFIG) { strcpy(reg_key_name_buf, reg_class_names[i]); export_hkey(file, reg_class_keys[i], ®_key_name_buf, ®_key_name_len, @@ -1465,8 +1379,7 @@ } } - if (file) - { + if (file) { fclose(file); } HeapFree(GetProcessHeap(), 0, reg_key_name); @@ -1501,8 +1414,7 @@ LONG ret; long int i; - if (RegOpenKey(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) - { + if (RegOpenKey(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) { REGPROC_print_error(); } @@ -1510,8 +1422,7 @@ if (RegQueryInfoKey(branch_key, NULL, NULL, NULL, &subkeys, &max_sub_key_len, NULL, NULL, NULL, NULL, NULL, NULL - ) != ERROR_SUCCESS) - { + ) != ERROR_SUCCESS) { REGPROC_print_error(); } curr_len = strlen(*reg_key_name_buf); @@ -1519,16 +1430,14 @@ max_sub_key_len + curr_len + 1); (*reg_key_name_buf)[curr_len] = '\\'; - for (i = subkeys - 1; i >= 0; i--) - { + for (i = subkeys - 1; i >= 0; i--) { DWORD buf_len = *reg_key_name_len - curr_len; 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) - { + ret != ERROR_MORE_DATA && + ret != ERROR_NO_MORE_ITEMS) { REGPROC_print_error(); } else { delete_branch(key, reg_key_name_buf, reg_key_name_len); @@ -1557,8 +1466,7 @@ return; /* open the specified key */ reg_key_class = getRegClass(reg_key_name); - if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) - { + if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) { fprintf(stderr,"%s: Incorrect registry class specification in '%s'\n", getAppName(), reg_key_name); exit(1); @@ -1566,14 +1474,12 @@ branch_name = getRegKeyName(reg_key_name); CHECK_ENOUGH_MEMORY(branch_name); branch_name_len = strlen(branch_name); - if (!branch_name[0]) - { + if (!branch_name[0]) { fprintf(stderr,"%s: Can't delete registry class '%s'\n", getAppName(), reg_key_name); exit(1); } - if (RegOpenKey(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); Index: programs/regedit/regproc.h =================================================================== RCS file: /var/cvs/wine/programs/regedit/regproc.h,v retrieving revision 1.3 diff -u -r1.3 regproc.h --- programs/regedit/regproc.h 7 Aug 2003 03:10:13 -0000 1.3 +++ programs/regedit/regproc.h 6 Dec 2003 06:55:21 -0000 @@ -49,7 +49,7 @@ * Generic prototypes */ char* getToken(char** str, const char* delims); -void get_file_name(CHAR **command_line, CHAR *filename); +void get_file_name(CHAR **command_line, CHAR *filename); DWORD convertHexToDWord(char *str, BYTE *buf); DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen); LPSTR convertHexToHexCSV( BYTE *buf, ULONG len); Index: programs/regedit/treeview.c =================================================================== RCS file: /var/cvs/wine/programs/regedit/treeview.c,v retrieving revision 1.3 diff -u -r1.3 treeview.c --- programs/regedit/treeview.c 3 Dec 2003 20:25:24 -0000 1.3 +++ programs/regedit/treeview.c 8 Dec 2003 04:51:05 -0000 @@ -72,7 +72,7 @@ hKey = (HKEY)item.lParam; item.mask = TVIF_TEXT; item.hItem = hItem; -/* item.pszText = &keyPath[*pPathLen]; */ + /* item.pszText = &keyPath[*pPathLen]; */ item.pszText = keyPath; item.cchTextMax = max; if (TreeView_GetItem(hwndTV, &item)) { @@ -150,7 +150,7 @@ /* Create the image list. */ if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, - FALSE, NUM_BITMAPS, 0)) == NULL) + FALSE, NUM_BITMAPS, 0)) == NULL) return FALSE; /* Add the open file, closed file, and document bitmaps. */ @@ -213,7 +213,7 @@ if (errCode == ERROR_SUCCESS) { TCHAR SubName[MAX_NAME_LEN]; DWORD cSubName = MAX_NAME_LEN; -/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */ + /* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */ while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { ++dwCount; } @@ -223,11 +223,10 @@ cName = MAX_NAME_LEN; ++dwIndex; } - /*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */ + /*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */ RegCloseKey(hNewKey); } - } else { - } + } else {} expanding = FALSE; return TRUE; } @@ -246,9 +245,9 @@ /* Get the dimensions of the parent window's client area, and create the tree view control. */ GetClientRect(hwndParent, &rcClient); hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"), - WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, - 0, 0, rcClient.right, rcClient.bottom, - hwndParent, (HMENU)id, hInst, NULL); + WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, + 0, 0, rcClient.right, rcClient.bottom, + hwndParent, (HMENU)id, hInst, NULL); /* Initialize the image list, and add items to the control. */ if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) { DestroyWindow(hwndTV); -- Dimi.