~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/drivers/windows/gldirect/ddlog.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
*
3
 
*                        Mesa 3-D graphics library
4
 
*                        Direct3D Driver Interface
5
 
*
6
 
*  ========================================================================
7
 
*
8
 
*   Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9
 
*
10
 
*   Permission is hereby granted, free of charge, to any person obtaining a
11
 
*   copy of this software and associated documentation files (the "Software"),
12
 
*   to deal in the Software without restriction, including without limitation
13
 
*   the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
 
*   and/or sell copies of the Software, and to permit persons to whom the
15
 
*   Software is furnished to do so, subject to the following conditions:
16
 
*
17
 
*   The above copyright notice and this permission notice shall be included
18
 
*   in all copies or substantial portions of the Software.
19
 
*
20
 
*   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 
*   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 
*   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23
 
*   SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
 
*   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25
 
*   OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
 
*   SOFTWARE.
27
 
*
28
 
*  ======================================================================
29
 
*
30
 
* Language:     ANSI C
31
 
* Environment:  Windows 9x (Win32)
32
 
*
33
 
* Description:  Logging functions.
34
 
*
35
 
****************************************************************************/
36
 
 
37
 
#define STRICT
38
 
#include <windows.h>
39
 
 
40
 
#include "ddlog.h"
41
 
#include "gld_driver.h"
42
 
 
43
 
// ***********************************************************************
44
 
 
45
 
static char                                             ddlogbuf[256];
46
 
static FILE*                                    fpDDLog = NULL; // Log file pointer
47
 
static char                                             szDDLogName[_MAX_PATH] = {"gldirect.log"};      // Filename of the log
48
 
static DDLOG_loggingMethodType  ddlogLoggingMethod = DDLOG_NONE;        // Default to No Logging
49
 
static DDLOG_severityType               ddlogDebugLevel;
50
 
static BOOL                                             bUIWarning = FALSE;     // MessageBox warning ?
51
 
 
52
 
// ***********************************************************************
53
 
 
54
 
void ddlogOpen(
55
 
        DDLOG_loggingMethodType LoggingMethod,
56
 
        DDLOG_severityType Severity)
57
 
{
58
 
        if (fpDDLog != NULL) {
59
 
                // Tried to re-open the log
60
 
                ddlogMessage(DDLOG_WARN, "Tried to re-open the log file\n");
61
 
                return;
62
 
        }
63
 
 
64
 
        ddlogLoggingMethod = LoggingMethod;
65
 
        ddlogDebugLevel = Severity;
66
 
 
67
 
        if (ddlogLoggingMethod == DDLOG_NORMAL) {
68
 
                fpDDLog = fopen(szDDLogName, "wt");
69
 
        if (fpDDLog == NULL)
70
 
            return;
71
 
    }
72
 
 
73
 
        ddlogMessage(DDLOG_SYSTEM, "\n");
74
 
        ddlogMessage(DDLOG_SYSTEM, "-> Logging Started\n");
75
 
}
76
 
 
77
 
// ***********************************************************************
78
 
 
79
 
void ddlogClose()
80
 
{
81
 
        // Determine whether the log is already closed
82
 
        if (fpDDLog == NULL && ddlogLoggingMethod == DDLOG_NORMAL)
83
 
                return; // Nothing to do.
84
 
 
85
 
        ddlogMessage(DDLOG_SYSTEM, "<- Logging Ended\n");
86
 
 
87
 
        if (ddlogLoggingMethod == DDLOG_NORMAL) {
88
 
                fclose(fpDDLog);
89
 
                fpDDLog = NULL;
90
 
        }
91
 
}
92
 
 
93
 
// ***********************************************************************
94
 
 
95
 
void ddlogMessage(
96
 
        DDLOG_severityType severity,
97
 
        LPSTR message)
98
 
{
99
 
        char buf[256];
100
 
 
101
 
        // Bail if logging is disabled
102
 
        if (ddlogLoggingMethod == DDLOG_NONE)
103
 
                return;
104
 
 
105
 
        if (ddlogLoggingMethod == DDLOG_CRASHPROOF)
106
 
                fpDDLog = fopen(szDDLogName, "at");
107
 
 
108
 
        if (fpDDLog == NULL)
109
 
                return;
110
 
 
111
 
        if (severity >= ddlogDebugLevel) {
112
 
                sprintf(buf, "DDLog: (%s) %s", ddlogSeverityMessages[severity], message);
113
 
                fputs(buf, fpDDLog); // Write string to file
114
 
                OutputDebugString(buf); // Echo to debugger
115
 
        }
116
 
 
117
 
        if (ddlogLoggingMethod == DDLOG_CRASHPROOF) {
118
 
                fflush(fpDDLog); // Write info to disk
119
 
                fclose(fpDDLog);
120
 
                fpDDLog = NULL;
121
 
        }
122
 
 
123
 
        // Popup message box if critical error
124
 
        if (bUIWarning && severity == DDLOG_CRITICAL) {
125
 
                MessageBox(NULL, buf, "GLDirect", MB_OK | MB_ICONWARNING | MB_TASKMODAL);
126
 
        }
127
 
}
128
 
 
129
 
// ***********************************************************************
130
 
 
131
 
// Write a string value to the log file
132
 
void ddlogError(
133
 
        DDLOG_severityType severity,
134
 
        LPSTR message,
135
 
        HRESULT hResult)
136
 
{
137
 
#ifdef _USE_GLD3_WGL
138
 
        char dxErrStr[1024];
139
 
        _gldDriver.GetDXErrorString(hResult, &dxErrStr[0], sizeof(dxErrStr));
140
 
        if (FAILED(hResult)) {
141
 
                sprintf(ddlogbuf, "DDLog: %s %8x:[ %s ]\n", message, hResult, dxErrStr);
142
 
        } else
143
 
                sprintf(ddlogbuf, "DDLog: %s\n", message);
144
 
#else
145
 
        if (FAILED(hResult)) {
146
 
                sprintf(ddlogbuf, "DDLog: %s %8x:[ %s ]\n", message, hResult, DDErrorToString(hResult));
147
 
        } else
148
 
                sprintf(ddlogbuf, "DDLog: %s\n", message);
149
 
#endif
150
 
        ddlogMessage(severity, ddlogbuf);
151
 
}
152
 
 
153
 
// ***********************************************************************
154
 
 
155
 
void ddlogPrintf(
156
 
        DDLOG_severityType severity,
157
 
        LPSTR message,
158
 
        ...)
159
 
{
160
 
        va_list args;
161
 
 
162
 
        va_start(args, message);
163
 
        vsprintf(ddlogbuf, message, args);
164
 
        va_end(args);
165
 
 
166
 
        lstrcat(ddlogbuf, "\n");
167
 
 
168
 
        ddlogMessage(severity, ddlogbuf);
169
 
}
170
 
 
171
 
// ***********************************************************************
172
 
 
173
 
void ddlogWarnOption(
174
 
        BOOL bWarnOption)
175
 
{
176
 
        bUIWarning = bWarnOption;
177
 
}
178
 
 
179
 
// ***********************************************************************
180
 
 
181
 
void ddlogPathOption(
182
 
        LPSTR szPath)
183
 
{
184
 
        char szPathName[_MAX_PATH];
185
 
 
186
 
        strcpy(szPathName, szPath);
187
 
    strcat(szPathName, "\\");
188
 
    strcat(szPathName, szDDLogName);
189
 
    strcpy(szDDLogName, szPathName);
190
 
}
191
 
 
192
 
// ***********************************************************************