mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
Added command line handling from wine regedit, removed stdafx rubbish.
Builds cleanly and executes but no run-time testing as yet - beware. svn path=/trunk/; revision=3436
This commit is contained in:
parent
0a0f2c9c13
commit
d173db00ea
14 changed files with 1703 additions and 130 deletions
|
@ -36,6 +36,8 @@ OBJS = framewnd.o \
|
|||
about.o \
|
||||
trace.o \
|
||||
hex_str.o \
|
||||
regcmds.o \
|
||||
regproc.o \
|
||||
main.o
|
||||
|
||||
LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// regedit.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
|
@ -1,33 +0,0 @@
|
|||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
||||
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// Local Header Files
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,7 +29,6 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "about.h"
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,7 +29,6 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#define ASSERT assert
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,7 +29,6 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "about.h"
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,11 +29,11 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <windowsx.h>
|
||||
#include "main.h"
|
||||
#include "listview.h"
|
||||
#include "hex_str.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -88,21 +85,21 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
|||
case REG_DWORD:
|
||||
{
|
||||
TCHAR buf[64];
|
||||
wsprintf(buf, "0x%08X (%d)", *(DWORD*)ValBuf, *(DWORD*)ValBuf);
|
||||
wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
|
||||
ListView_SetItemText(hwndLV, index, 2, buf);
|
||||
}
|
||||
// lpsRes = convertHexToDWORDStr(lpbData, dwLen);
|
||||
break;
|
||||
case REG_BINARY:
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
LPTSTR pData = (LPTSTR)ValBuf;
|
||||
LPTSTR strBinary = malloc(dwCount * sizeof(TCHAR) * 3 + 1);
|
||||
memset(strBinary, _T(' '), dwCount * sizeof(TCHAR) * 3);
|
||||
strBinary[dwCount * sizeof(TCHAR) * 3] = _T('\0');
|
||||
for (i = 0; i < dwCount; i++) {
|
||||
unsigned short* pShort;
|
||||
pShort = &(strBinary[i*3]);
|
||||
pShort = (unsigned short*)&(strBinary[i*3]);
|
||||
// strBinary[i*3] = Byte2Hex((LPTSTR)ValBuf+i);
|
||||
// *pShort++ = Byte2Hex(*(pData+i));
|
||||
*pShort = Byte2Hex(*(pData+i));
|
||||
|
@ -202,6 +199,7 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
TCHAR buf1[1000];
|
||||
|
@ -211,6 +209,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
|
|||
ListView_GetItemText((HWND)lParamSort, lParam2, 0, buf2, sizeof(buf2));
|
||||
return _tcscmp(buf1, buf2);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ListViewPopUpMenu(HWND hWnd, POINT pt)
|
||||
{
|
||||
|
@ -363,7 +362,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
|
|||
// }
|
||||
// dwValSize = max_val_size;
|
||||
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) {
|
||||
ValBuf[dwValSize] = NULL;
|
||||
ValBuf[dwValSize] = 0;
|
||||
AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize);
|
||||
dwValNameLen = max_val_name_len;
|
||||
dwValSize = max_val_size;
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,13 +29,15 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "framewnd.h"
|
||||
#include "childwnd.h"
|
||||
|
||||
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Global Variables:
|
||||
//
|
||||
|
@ -102,6 +101,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
};
|
||||
ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class
|
||||
hChildWndClass = hChildWndClass; // warning eater
|
||||
|
||||
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
|
||||
|
||||
|
@ -137,7 +137,6 @@ void ExitInstance(void)
|
|||
DestroyMenu(hMenuFrame);
|
||||
}
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
|
@ -146,6 +145,10 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||
MSG msg;
|
||||
HACCEL hAccel;
|
||||
|
||||
if (ProcessCmdLine(lpCmdLine)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialize global strings
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
|
||||
|
|
222
rosapps/regedit/regcmds.c
Normal file
222
rosapps/regedit/regcmds.c
Normal file
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* ReactOS regedit
|
||||
*
|
||||
* regcmds.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* Original Work Copyright 2002 Andriy Palamarchuk
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#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>
|
||||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include "regproc.h"
|
||||
#include "main.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Global Variables:
|
||||
//
|
||||
|
||||
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";
|
||||
|
||||
typedef enum {
|
||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||
} REGEDIT_ACTION;
|
||||
|
||||
/**
|
||||
* Process unknown switch.
|
||||
*
|
||||
* Params:
|
||||
* chu - the switch character in upper-case.
|
||||
* s - the command line string where s points to the switch character.
|
||||
*/
|
||||
void error_unknown_switch(char chu, char *s)
|
||||
{
|
||||
if (isalpha(chu)) {
|
||||
printf("%s: Undefined switch /%c!\n", getAppName(), chu);
|
||||
} else {
|
||||
printf("%s: Alphabetic character is expected after '%c' "
|
||||
"in switch specification\n", getAppName(), *(s - 1));
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
||||
{
|
||||
REGEDIT_ACTION action = ACTION_UNDEF;
|
||||
LPSTR s = lpCmdLine; /* command line pointer */
|
||||
CHAR ch = *s; /* current character */
|
||||
|
||||
setAppName("regedit");
|
||||
while (ch && ((ch == '-') || (ch == '/'))) {
|
||||
char chu;
|
||||
char ch2;
|
||||
|
||||
s++;
|
||||
ch = *s;
|
||||
ch2 = *(s+1);
|
||||
chu = toupper(ch);
|
||||
if (!ch2 || isspace(ch2)) {
|
||||
if (chu == 'S' || chu == 'V') {
|
||||
/* ignore these switches */
|
||||
} else {
|
||||
switch (chu) {
|
||||
case 'D':
|
||||
action = ACTION_DELETE;
|
||||
break;
|
||||
case 'E':
|
||||
action = ACTION_EXPORT;
|
||||
break;
|
||||
case '?':
|
||||
printf(usage);
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
error_unknown_switch(chu, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
s++;
|
||||
} else {
|
||||
if (ch2 == ':') {
|
||||
switch (chu) {
|
||||
case 'L':
|
||||
/* fall through */
|
||||
case 'R':
|
||||
s += 2;
|
||||
while (*s && !isspace(*s)) {
|
||||
s++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_unknown_switch(chu, s);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* this is a file name, starting from '/' */
|
||||
s--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* skip spaces to the next parameter */
|
||||
ch = *s;
|
||||
while (ch && isspace(ch)) {
|
||||
s++;
|
||||
ch = *s;
|
||||
}
|
||||
}
|
||||
// if (action == ACTION_UNDEF) {
|
||||
// action = ACTION_ADD;
|
||||
// }
|
||||
|
||||
switch (action) {
|
||||
case ACTION_ADD:
|
||||
{
|
||||
CHAR filename[MAX_PATH];
|
||||
FILE *reg_file;
|
||||
get_file_name(&s, filename);
|
||||
if (!filename[0]) {
|
||||
printf("%s: No file name is specified\n%s", getAppName(), usage);
|
||||
exit(1);
|
||||
}
|
||||
while (filename[0]) {
|
||||
reg_file = fopen(filename, "r");
|
||||
if (reg_file) {
|
||||
processRegLines(reg_file, doSetValue);
|
||||
} else {
|
||||
perror("");
|
||||
printf("%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);
|
||||
if (!reg_key_name[0]) {
|
||||
printf("%s: No registry key is specified for removal\n%s", getAppName(), 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]) {
|
||||
printf("%s: No file name is specified\n%s", getAppName(), 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;
|
||||
}
|
||||
default:
|
||||
printf("%s: Unhandled action!\n", getAppName());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
1373
rosapps/regedit/regproc.c
Normal file
1373
rosapps/regedit/regproc.c
Normal file
File diff suppressed because it is too large
Load diff
73
rosapps/regedit/regproc.h
Normal file
73
rosapps/regedit/regproc.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 1999 Sylvain St-Germain
|
||||
* Copyright 2002 Andriy Palamarchuk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Defines and consts
|
||||
*/
|
||||
#define KEY_MAX_LEN 1024
|
||||
|
||||
/* Return values */
|
||||
#define SUCCESS 0
|
||||
#define KEY_VALUE_ALREADY_SET 2
|
||||
|
||||
typedef void (*CommandAPI)(LPSTR lpsLine);
|
||||
|
||||
void doSetValue(LPSTR lpsLine);
|
||||
void doDeleteValue(LPSTR lpsLine);
|
||||
void doCreateKey(LPSTR lpsLine);
|
||||
void doDeleteKey(LPSTR lpsLine);
|
||||
void doQueryValue(LPSTR lpsLine);
|
||||
void doRegisterDLL(LPSTR lpsLine);
|
||||
void doUnregisterDLL(LPSTR lpsLine);
|
||||
|
||||
void export_registry_key(CHAR* file_name, CHAR* reg_key_name);
|
||||
void delete_registry_key(CHAR* reg_key_name);
|
||||
|
||||
void setAppName(CHAR* name);
|
||||
CHAR* getAppName(VOID);
|
||||
|
||||
void processRegLines(FILE* in, CommandAPI command);
|
||||
|
||||
/*
|
||||
* Generic prototypes
|
||||
*/
|
||||
char* getToken(char** str, const char* delims);
|
||||
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);
|
||||
LPSTR convertHexToDWORDStr(BYTE* buf, ULONG len);
|
||||
LPSTR getRegKeyName(LPSTR lpLine);
|
||||
HKEY getRegClass(LPSTR lpLine);
|
||||
DWORD getDataType(LPSTR* lpValue, DWORD* parse_type);
|
||||
LPSTR getArg(LPSTR arg);
|
||||
HRESULT openKey(LPSTR stdInput);
|
||||
void closeKey(VOID);
|
||||
|
||||
/*
|
||||
* api setValue prototypes
|
||||
*/
|
||||
void processSetValue(LPSTR cmdline);
|
||||
HRESULT setValue(LPSTR val_name, LPSTR val_data);
|
||||
|
||||
/*
|
||||
* api queryValue prototypes
|
||||
*/
|
||||
void processQueryValue(LPSTR cmdline);
|
||||
|
|
@ -4,35 +4,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "windows.h"
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "trace.h"
|
||||
|
||||
DeclAssertFile; // Should be added at the begining of each .C/.CPP
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef WIN32
|
||||
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
//#include <windows.h>
|
||||
//#include <assert.h>
|
||||
//WINBASEAPI VOID WINAPI DebugBreak(VOID);
|
||||
//WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString);
|
||||
//WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString);
|
||||
//void __stdcall DebugBreak(void);
|
||||
//void __stdcall OutputDebugStringA(char* lpOutputString);
|
||||
//void __stdcall OutputDebugStringW(wchar_t* lpOutputString);
|
||||
#ifdef UNICODE
|
||||
#define OutputDebugString OutputDebugStringW
|
||||
#else
|
||||
#define OutputDebugString OutputDebugStringA
|
||||
#endif // !UNICODE
|
||||
|
||||
#else
|
||||
#include "hardware.h"
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
|
@ -48,16 +26,10 @@ void Trace(TCHAR* lpszFormat, ...)
|
|||
TCHAR szBuffer[512];
|
||||
|
||||
va_start(args, lpszFormat);
|
||||
// nBuf = vsprintf(szBuffer, lpszFormat, args);
|
||||
// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
|
||||
#ifdef _UNICODE
|
||||
nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
#else
|
||||
nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
#endif
|
||||
nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
OutputDebugString(szBuffer);
|
||||
// was there an error? was the expanded string too long?
|
||||
// ASSERT(nBuf >= 0);
|
||||
//ASSERT(nBuf >= 0);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
@ -72,11 +44,8 @@ void Assert(void* assert, TCHAR* file, int line, void* msg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
//inline void Trace(TCHAR* lpszFormat, ...) { };
|
||||
//inline void Assert(void* assert, TCHAR* file, int line, void* msg) { };
|
||||
void Trace(TCHAR* lpszFormat, ...) { };
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg) { };
|
||||
|
||||
|
|
|
@ -1,39 +1,30 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#ifndef __TRACE_H__
|
||||
#define __TRACE_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
//=============================================================================
|
||||
// BreakPoint() macro.
|
||||
//=============================================================================
|
||||
|
||||
#ifdef _X86_
|
||||
#define BreakPoint() _asm { int 3h }
|
||||
#else
|
||||
#define BreakPoint() _DebugBreak()
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
// MACRO: ASSERT()
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp) \
|
||||
{ \
|
||||
if ( !(exp) ) \
|
||||
{ \
|
||||
Assert(#exp, __FILE__, __LINE__, NULL); \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, NULL); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#define ASSERTMSG(exp, msg) \
|
||||
{ \
|
||||
if ( !(exp) ) \
|
||||
{ \
|
||||
Assert(#exp, __FILE__, __LINE__, msg); \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, msg); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
}
|
||||
|
@ -43,30 +34,28 @@
|
|||
// MACRO: TRACE()
|
||||
//=============================================================================
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg);
|
||||
void Trace(TCHAR* lpszFormat, ...);
|
||||
void Trace1(int code, TCHAR* lpszFormat, ...);
|
||||
|
||||
#define TRACE Trace
|
||||
#define TRACE0 Trace
|
||||
|
||||
|
||||
#else // _DEBUG
|
||||
|
||||
//=============================================================================
|
||||
// Define away MACRO's ASSERT() and TRACE() in non debug builds
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#define ASSERTMSG(exp, msg)
|
||||
#endif
|
||||
|
||||
//#define TRACE0 TRACE
|
||||
//#define TRACE1 TRACE
|
||||
#define TRACE 0 ? (void)0 : Trace
|
||||
|
||||
#endif // !_DEBUG
|
||||
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg);
|
||||
void Trace(TCHAR* lpszFormat, ...);
|
||||
|
||||
#define TRACE 0 ? (void)0 : Trace
|
||||
|
||||
|
||||
#endif // !_DEBUG
|
||||
|
||||
#endif // __TRACE_H__
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -32,7 +29,6 @@
|
|||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "treeview.h"
|
||||
|
|
Loading…
Reference in a new issue