Just getting in sync with removal of obsolete #pragma directive.

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
This commit is contained in:
Robert Dickenson 2002-11-13 12:08:26 +00:00
parent e2d799f080
commit d4293289b3
13 changed files with 67 additions and 69 deletions

View 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>

View 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>

View file

@ -27,10 +27,6 @@
extern "C" {
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);

View 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>

View 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

View file

@ -27,10 +27,6 @@
extern "C" {
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);

View 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);

View file

@ -27,10 +27,6 @@
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);

View file

@ -24,11 +24,10 @@
#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;

View file

@ -27,9 +27,6 @@
extern "C" {
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"

View file

@ -24,17 +24,20 @@
#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>
#include <process.h>
#else
#ifndef __GNUC__
#include <tchar.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;

View 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>

View file

@ -27,10 +27,6 @@
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);