Just getting in sync with removal of obsolete #pragma directive.
authorRobert Dickenson <robd@reactos.org>
Wed, 13 Nov 2002 12:08:26 +0000 (12:08 +0000)
committerRobert Dickenson <robd@reactos.org>
Wed, 13 Nov 2002 12:08:26 +0000 (12:08 +0000)
New work soon to come. Having a bad time with heap corruption
when attempting to import massive reg scripts into the ROS registry.

svn path=/trunk/; revision=3752

13 files changed:
rosapps/regedit/about.c
rosapps/regedit/childwnd.c
rosapps/regedit/childwnd.h
rosapps/regedit/debug.c
rosapps/regedit/framewnd.c
rosapps/regedit/framewnd.h
rosapps/regedit/listview.c
rosapps/regedit/listview.h
rosapps/regedit/main.c
rosapps/regedit/main.h
rosapps/regedit/regcmds.c
rosapps/regedit/treeview.c
rosapps/regedit/treeview.h

index f7b75b8..6b98186 100644 (file)
@@ -24,8 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
index fc8918f..32f08d1 100644 (file)
@@ -24,8 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
index 1dd38a2..eb91603 100644 (file)
 extern "C" {
 #endif
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
 
 LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
     
index 2ca8eee..f449900 100644 (file)
@@ -27,8 +27,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
index 468aeb8..30f3b66 100644 (file)
@@ -25,7 +25,6 @@
 #include <commctrl.h>
 #include <stdlib.h>
 #include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
@@ -189,7 +188,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
         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
index 969739c..988ab97 100644 (file)
 extern "C" {
 #endif
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
 
 LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
 
index 5cebff7..5d19151 100644 (file)
@@ -25,7 +25,6 @@
 #include <commctrl.h>
 #include <stdlib.h>
 #include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
@@ -350,10 +349,13 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
             /* 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);
+
+#define BUF_HEAD_SPACE 2 // TODO: check why this is required with ROS ???
+
             if (errCode == ERROR_SUCCESS) {
-                TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR));
+                TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE);
                 DWORD dwValNameLen = max_val_name_len;
-                BYTE* ValBuf = malloc(++max_val_size);
+                BYTE* ValBuf = malloc(++max_val_size/* + BUF_HEAD_SPACE*/);
                 DWORD dwValSize = max_val_size;
                 DWORD dwIndex = 0L;
                 DWORD dwValType;
@@ -369,8 +371,10 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
                     dwValType = 0L;
                     ++dwIndex;
                 }
+
                 free(ValBuf);
                 free(ValName);
+
             }
             //ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV);
 //            SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV);
index a90aef3..565960c 100644 (file)
 extern "C" {
 #endif
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
 
 HWND CreateListView(HWND hwndParent, int id);
 BOOL RefreshListView(HWND hwndTV, HKEY hKey, LPTSTR keyPath);
index dd6d6b1..7efca1d 100644 (file)
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
+#include <fcntl.h>
     
 #include "main.h"
 #include "framewnd.h"
@@ -144,6 +143,20 @@ int APIENTRY WinMain(HINSTANCE hInstance,
 {
     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;
+ */
 
     if (ProcessCmdLine(lpCmdLine)) {
         return 0;
index 985df76..c0ba654 100644 (file)
@@ -27,9 +27,6 @@
 extern "C" {
 #endif
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
 
 #include "resource.h"
 
index 5c00f72..ea71432 100644 (file)
 
 #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
 #include <windows.h>
-#include <commctrl.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
+#ifndef WIN32_REGDBG
+#include <tchar.h>
+#else
+#ifndef __GNUC__
 #include <tchar.h>
-#include <process.h>
+#endif
+#define _tfopen     _wfopen
+#include <memory.h>
+#endif
 #include <stdio.h>
-    
 #include <ctype.h>
+
 #include "regproc.h"
-#include "main.h"
+
 
 ////////////////////////////////////////////////////////////////////////////////
 // Global Variables:
@@ -86,12 +89,12 @@ typedef enum {
 void error_unknown_switch(char chu, char *s)
 {
     if (isalpha(chu)) {
-        printf("%s: Undefined switch /%c!\n", getAppName(), chu);
+        printf("Undefined switch /%c!\n", chu);
     } else {
-        printf("%s: Alphabetic character is expected after '%c' "
-               "in switch specification\n", getAppName(), *(s - 1));
+        printf("Alphabetic character is expected after '%c' "
+               "in switch specification\n", *(s - 1));
     }
-    exit(1);
+    //exit(1);
 }
 
 BOOL ProcessCmdLine(LPSTR lpCmdLine)
@@ -100,7 +103,6 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
     LPSTR s = lpCmdLine;        /* command line pointer */
     CHAR ch = *s;               /* current character */
 
-    setAppName("regedit");
     while (ch && ((ch == '-') || (ch == '/'))) {
         char chu;
         char ch2;
@@ -122,10 +124,12 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
                     break;
                 case '?':
                     printf(usage);
-                    exit(0);
+                    return FALSE;
+                    //exit(0);
                     break;
                 default:
                     error_unknown_switch(chu, s);
+                    return FALSE;
                     break;
                 }
             }
@@ -143,6 +147,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
                     break;
                 default:
                     error_unknown_switch(chu, s);
+                    return FALSE;
                     break;
                 }
             } else {
@@ -158,56 +163,60 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
             ch = *s;
         }
     }
-//    if (action == ACTION_UNDEF) {
-//        action = ACTION_ADD;
-//    }
+    if (action == ACTION_UNDEF) {
+        action = ACTION_ADD;
+    }
 
     switch (action) {
     case ACTION_ADD:
     {
-        CHAR filename[MAX_PATH];
+        TCHAR filename[MAX_PATH];
         FILE *reg_file;
-        get_file_name(&s, filename);
+        get_file_name(&s, filename, MAX_PATH);
         if (!filename[0]) {
-            printf("%s: No file name is specified\n%s", getAppName(), usage);
-            exit(1);
+            printf("No file name is specified\n%s", usage);
+            return FALSE;
+            //exit(1);
         }
         while (filename[0]) {
-            reg_file = fopen(filename, "r");
+            reg_file = _tfopen(filename, _T("r"));
             if (reg_file) {
                 processRegLines(reg_file, doSetValue);
             } else {
                 perror("");
-                printf("%s: Can't open file \"%s\"\n", getAppName(), filename);
-                exit(1);
+                printf("Can't open file \"%s\"\n", filename);
+                return FALSE;
+                //exit(1);
             }
-            get_file_name(&s, filename);
+            get_file_name(&s, filename, MAX_PATH);
         }
         break;
     }
     case ACTION_DELETE:
     {
-        CHAR reg_key_name[KEY_MAX_LEN];
-        get_file_name(&s, reg_key_name);
+        TCHAR reg_key_name[KEY_MAX_LEN];
+        get_file_name(&s, reg_key_name, KEY_MAX_LEN);
         if (!reg_key_name[0]) {
-            printf("%s: No registry key is specified for removal\n%s", getAppName(), usage);
-            exit(1);
+            printf("No registry key is specified for removal\n%s", usage);
+            return FALSE;
+            //exit(1);
         }
         delete_registry_key(reg_key_name);
         break;
     }
     case ACTION_EXPORT:
     {
-        CHAR filename[MAX_PATH];
+        TCHAR filename[MAX_PATH];
         filename[0] = '\0';
-        get_file_name(&s, filename);
+        get_file_name(&s, filename, MAX_PATH);
         if (!filename[0]) {
-            printf("%s: No file name is specified\n%s", getAppName(), usage);
-            exit(1);
+            printf("No file name is specified\n%s", usage);
+            return FALSE;
+            //exit(1);
         }
         if (s[0]) {
-            CHAR reg_key_name[KEY_MAX_LEN];
-            get_file_name(&s, reg_key_name);
+            TCHAR reg_key_name[KEY_MAX_LEN];
+            get_file_name(&s, reg_key_name, KEY_MAX_LEN);
             export_registry_key(filename, reg_key_name);
         } else {
             export_registry_key(filename, NULL);
@@ -215,7 +224,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
         break;
     }
     default:
-        printf("%s: Unhandled action!\n", getAppName());
+        printf("Unhandled action!\n");
         return FALSE;
     }
     return TRUE;
index b151df3..208b6b1 100644 (file)
@@ -24,8 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
 #include <tchar.h>
 #include <process.h>
 #include <stdio.h>
index 18b5756..9f971e0 100644 (file)
 extern "C" {
 #endif
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
 
 HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
 BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);