VirtualBox

source: vbox/trunk/src/recompiler/InnoTek/loghack.c@ 1939

Last change on this file since 1939 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/** @file
2 *
3 * Hack for fprintf(logfile, ...) and printf to tee that onto the debugger.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#define LOG_GROUP LOG_GROUP_REM_PRINTF
26#include <VBox/log.h>
27
28#include <stdio.h>
29#include <stdarg.h>
30
31
32/**
33 * Wrapper for fprintf().
34 */
35int hacked_fprintf(FILE *pFile, const char *pszFormat, ...)
36{
37 va_list args;
38 int rc;
39 int rc2;
40 static char szBuffer[16384];
41
42 va_start(args, pszFormat);
43 rc = vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, args);
44 va_end(args);
45
46 if (rc >= sizeof(szBuffer))
47 rc = sizeof(szBuffer) - 1;
48 if (rc <= 0 || (szBuffer[rc - 1] != '\r' && szBuffer[rc - 1] != '\n'))
49 Log(("VBoxREM: %s\n", szBuffer));
50 else
51 Log(("VBoxREM: %s", szBuffer));
52
53 rc2 = rc;
54#ifndef DEBUG_sandervl
55 if (pFile && pFile != stderr && pFile != stdout && pFile != stdin)
56 {
57 va_start(args, pszFormat);
58 rc2 = vfprintf(pFile, pszFormat, args);
59 va_end(args);
60 }
61#endif
62 return rc2;
63}
64
65/**
66 * Wrapper for printf().
67 */
68int hacked_printf(const char *pszFormat, ...)
69{
70 va_list args;
71 int rc;
72 static char szBuffer[16384];
73
74 va_start(args, pszFormat);
75 rc = vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, args);
76 va_end(args);
77
78 if (rc >= sizeof(szBuffer))
79 rc = sizeof(szBuffer) - 1;
80 if (rc <= 0 || (szBuffer[rc - 1] != '\r' && szBuffer[rc - 1] != '\n'))
81 Log(("VBoxREM: %s\n", szBuffer));
82 else
83 Log(("VBoxREM: %s", szBuffer));
84
85 return rc;
86}
87
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette