AccessBridgeDebug.cpp revision 12937:aa49cbb03b23
1169691Skan/* 2169691Skan * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. 3169691Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4169691Skan * 5169691Skan * This code is free software; you can redistribute it and/or modify it 6169691Skan * under the terms of the GNU General Public License version 2 only, as 7169691Skan * published by the Free Software Foundation. Oracle designates this 8169691Skan * particular file as subject to the "Classpath" exception as provided 9169691Skan * by Oracle in the LICENSE file that accompanied this code. 10169691Skan * 11169691Skan * This code is distributed in the hope that it will be useful, but WITHOUT 12169691Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13169691Skan * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14169691Skan * version 2 for more details (a copy is included in the LICENSE file that 15169691Skan * accompanied this code). 16169691Skan * 17169691Skan * You should have received a copy of the GNU General Public License version 18169691Skan * 2 along with this work; if not, write to the Free Software Foundation, 19169691Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20169691Skan * 21169691Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22169691Skan * or visit www.oracle.com if you need additional information or have any 23169691Skan * questions. 24169691Skan */ 25169691Skan 26169691Skan/* 27169691Skan * A class to manage AccessBridge debugging 28169691Skan */ 29169691Skan 30169691Skan#include "AccessBridgeDebug.h" 31169691Skan#include <stdarg.h> 32169691Skan#include <stdio.h> 33169691Skan#include <windows.h> 34169691Skan 35169691Skan#ifdef __cplusplus 36169691Skanextern "C" { 37169691Skan#endif 38169691Skan 39169691Skan /** 40169691Skan * Send debugging info to the appropriate place 41169691Skan */ 42169691Skan void PrintDebugString(char *msg, ...) { 43169691Skan#ifdef DEBUGGING_ON 44169691Skan char buf[1024]; 45169691Skan va_list argprt; 46169691Skan 47169691Skan va_start(argprt, msg); // set up argptr 48169691Skan vsprintf(buf, msg, argprt); 49169691Skan#ifdef SEND_TO_OUTPUT_DEBUG_STRING 50169691Skan OutputDebugString(buf); 51169691Skan#endif 52169691Skan#ifdef SEND_TO_CONSOLE 53169691Skan printf(buf); 54169691Skan printf("\r\n"); 55169691Skan#endif 56169691Skan#endif 57169691Skan } 58169691Skan 59169691Skan /** 60169691Skan * Send Java debugging info to the appropriate place 61169691Skan */ 62169691Skan void PrintJavaDebugString2(char *msg, ...) { 63169691Skan#ifdef JAVA_DEBUGGING_ON 64169691Skan char buf[1024]; 65169691Skan va_list argprt; 66169691Skan 67169691Skan va_start(argprt, msg); // set up argptr 68169691Skan vsprintf(buf, msg, argprt); 69169691Skan#ifdef SEND_TO_OUTPUT_DEBUG_STRING 70169691Skan OutputDebugString(buf); 71169691Skan#endif 72169691Skan#ifdef SEND_TO_CONSOLE 73169691Skan printf(buf); 74169691Skan printf("\r\n"); 75169691Skan#endif 76169691Skan#endif 77169691Skan } 78169691Skan /** 79169691Skan * Wide version of the method to send debugging info to the appropriate place 80169691Skan */ 81169691Skan void wPrintDebugString(wchar_t *msg, ...) { 82169691Skan#ifdef DEBUGGING_ON 83169691Skan char buf[1024]; 84169691Skan char charmsg[256]; 85169691Skan va_list argprt; 86169691Skan 87169691Skan va_start(argprt, msg); // set up argptr 88169691Skan sprintf(charmsg, "%ls", msg); // convert format string to multi-byte 89169691Skan vsprintf(buf, charmsg, argprt); 90169691Skan#ifdef SEND_TO_OUTPUT_DEBUG_STRING 91169691Skan OutputDebugString(buf); 92169691Skan#endif 93169691Skan#ifdef SEND_TO_CONSOLE 94169691Skan printf(buf); 95169691Skan printf("\r\n"); 96169691Skan#endif 97169691Skan#endif 98169691Skan } 99169691Skan 100169691Skan /** 101169691Skan * Wide version of the method to send Java debugging info to the appropriate place 102169691Skan */ 103169691Skan void wPrintJavaDebugString(wchar_t *msg, ...) { 104169691Skan#ifdef JAVA_DEBUGGING_ON 105169691Skan char buf[1024]; 106169691Skan char charmsg[256]; 107 va_list argprt; 108 109 va_start(argprt, msg); // set up argptr 110 sprintf(charmsg, "%ls", msg); // convert format string to multi-byte 111 vsprintf(buf, charmsg, argprt); 112#ifdef SEND_TO_OUTPUT_DEBUG_STRING 113 OutputDebugString(buf); 114#endif 115#ifdef SEND_TO_CONSOLE 116 printf(buf); 117 printf("\r\n"); 118#endif 119#endif 120 } 121#ifdef __cplusplus 122} 123#endif 124