Debug.cpp
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:7k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*******************************************************************************
- * Filename:
- * ---------
- * Debug.cpp
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- *
- *
- * Author:
- * -------
- *
- *
- *==============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *==============================================================================
- *******************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**************************************************************
- FILENAME : Debug.cpp
- PURPOSE : Functions to print debug messages on console. This file uses windows
- specific calls.
-
- REMARKS : nil
- AUTHOR : Vijay Vaidya
- DATE : Aug' 28, 2002
- **************************************************************/
- #include "stdafx.h"
- #include "PixtelDataTypes.h"
- extern "C" {
- #ifdef MMI_ON_WIN32
- extern HWND hWnd; /* main window handle */
- bool CtrlHandler(U32 fdwCtrlType) ; /* console CTRL signal handler */
- void ShutdownSystemOperation(void); /* shutdown system operations */
- #endif
- /**************************************************************
- FUNCTION NAME : DebugWindowAlloc
- PURPOSE : Allocate debug console to print debug messages
- INPUT PARAMETERS : nil
- OUTPUT PARAMETERS : nil
- RETURNS : void
- REMARKS :
- **************************************************************/
- void DebugWindowAlloc()
- {
- // [002]
- #ifdef MMI_ON_WIN32
-
- RECT rcClient; /* console window rectangle pos */
- HWND conshWnd; /* console window handle */
- /* allocates a new console for the calling process */
- if(!AllocConsole())
- {
- exit(1);
- }
- /* sets console window title */
- #ifdef __ASCII
- SetConsoleTitle(" Background Process ");
- #endif
- #ifdef __UCS2_ENCODING
- SetConsoleTitle(__TEXT(" Background Process "));
- #endif
- /* specified window into the foreground and activates the window */
- SetForegroundWindow(hWnd);
- /* gets handle for console window */
- conshWnd = GetWindow(hWnd, GW_HWNDNEXT);
- /* gets rect pos for console window */
- GetClientRect(conshWnd, &rcClient);
- /* sets console window pos */
- SetWindowPos(conshWnd, HWND_NOTOPMOST, rcClient.left+300, rcClient.top+40, 0, 0, SWP_NOSIZE);
-
- /* by default, the console window is minimized(forcing to minimize) */
- ShowWindow(conshWnd, SW_FORCEMINIMIZE);
- /* specified window into the foreground and activates the window */
- SetForegroundWindow(hWnd);
- /* sets console control handler */
- SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
- #endif
- // [002]
- }
- /**************************************************************
- FUNCTION NAME : DisplayToDebugwindow
- PURPOSE : To display messages on console
- INPUT PARAMETERS : nil
- OUTPUT PARAMETERS : nil
- RETURNS : void
- REMARKS :
- **************************************************************/
- // [003]
- #ifdef MMI_ON_WIN32
- void DisplayToDebugwindow(S8 *nPrintableStr)
- {
- HANDLE OutHndle = NULL; /* handle to screen buffer */
- unsigned long lpNumberOfCharsWritten = 0; /* number of characters written */
-
- /* retrieves a handle for the standard output */
- OutHndle = GetStdHandle(STD_OUTPUT_HANDLE);
-
- /* writes a character string to a console screen buffer beginning at the current cursor location */
- if(!WriteConsole(
- OutHndle, /* handle to screen buffer */
- nPrintableStr, /* write buffer */
- strlen(nPrintableStr), /* number of characters to write */
- &lpNumberOfCharsWritten, /* number of characters written */
- NULL /* reserved */
- ))
- {
- //return 0;
- }
- }
- #endif
- // [003]
-
- /**************************************************************
- FUNCTION NAME : CtrlHandler(unsigned long fdwCtrlType)
- PURPOSE : handles all CTRL signals
- INPUT PARAMETERS : nil
- OUTPUT PARAMETERS : nil
- RETURNS : void
- REMARKS : nil
- **************************************************************/
- #ifdef MMI_ON_WIN32
- bool CtrlHandler(U32 fdwCtrlType)
- {
- /* receives console CTRL signal type */
- switch (fdwCtrlType)
- {
- // [004]
- case CTRL_C_EVENT:
- case CTRL_CLOSE_EVENT:
- case CTRL_BREAK_EVENT:
- case CTRL_LOGOFF_EVENT:
- case CTRL_SHUTDOWN_EVENT:
- ShutdownSystemOperation();
- FreeConsole();
- return TRUE;
- // [004]
- default:
- return FALSE;
- }
- }
- #endif
- } //extern "C"