diff options
Diffstat (limited to 'src/bextutil/bextutil.cpp')
-rw-r--r-- | src/bextutil/bextutil.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp index baf35591..4b22d502 100644 --- a/src/bextutil/bextutil.cpp +++ b/src/bextutil/bextutil.cpp | |||
@@ -119,6 +119,29 @@ DAPIV_(HRESULT) BextLog( | |||
119 | { | 119 | { |
120 | HRESULT hr = S_OK; | 120 | HRESULT hr = S_OK; |
121 | va_list args; | 121 | va_list args; |
122 | |||
123 | if (!vpEngine) | ||
124 | { | ||
125 | hr = E_POINTER; | ||
126 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
127 | } | ||
128 | |||
129 | va_start(args, szFormat); | ||
130 | hr = BextLogArgs(level, szFormat, args); | ||
131 | va_end(args); | ||
132 | |||
133 | LExit: | ||
134 | return hr; | ||
135 | } | ||
136 | |||
137 | |||
138 | DAPI_(HRESULT) BextLogArgs( | ||
139 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
140 | __in_z __format_string LPCSTR szFormat, | ||
141 | __in va_list args | ||
142 | ) | ||
143 | { | ||
144 | HRESULT hr = S_OK; | ||
122 | LPSTR sczFormattedAnsi = NULL; | 145 | LPSTR sczFormattedAnsi = NULL; |
123 | LPWSTR sczMessage = NULL; | 146 | LPWSTR sczMessage = NULL; |
124 | 147 | ||
@@ -128,9 +151,7 @@ DAPIV_(HRESULT) BextLog( | |||
128 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | 151 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); |
129 | } | 152 | } |
130 | 153 | ||
131 | va_start(args, szFormat); | ||
132 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | 154 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); |
133 | va_end(args); | ||
134 | ExitOnFailure(hr, "Failed to format log string."); | 155 | ExitOnFailure(hr, "Failed to format log string."); |
135 | 156 | ||
136 | hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); | 157 | hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); |
@@ -153,6 +174,29 @@ DAPIV_(HRESULT) BextLogError( | |||
153 | { | 174 | { |
154 | HRESULT hr = S_OK; | 175 | HRESULT hr = S_OK; |
155 | va_list args; | 176 | va_list args; |
177 | |||
178 | if (!vpEngine) | ||
179 | { | ||
180 | hr = E_POINTER; | ||
181 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
182 | } | ||
183 | |||
184 | va_start(args, szFormat); | ||
185 | hr = BextLogErrorArgs(hrError, szFormat, args); | ||
186 | va_end(args); | ||
187 | |||
188 | LExit: | ||
189 | return hr; | ||
190 | } | ||
191 | |||
192 | |||
193 | DAPI_(HRESULT) BextLogErrorArgs( | ||
194 | __in HRESULT hrError, | ||
195 | __in_z __format_string LPCSTR szFormat, | ||
196 | __in va_list args | ||
197 | ) | ||
198 | { | ||
199 | HRESULT hr = S_OK; | ||
156 | LPSTR sczFormattedAnsi = NULL; | 200 | LPSTR sczFormattedAnsi = NULL; |
157 | LPWSTR sczMessage = NULL; | 201 | LPWSTR sczMessage = NULL; |
158 | 202 | ||
@@ -162,9 +206,7 @@ DAPIV_(HRESULT) BextLogError( | |||
162 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | 206 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); |
163 | } | 207 | } |
164 | 208 | ||
165 | va_start(args, szFormat); | ||
166 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | 209 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); |
167 | va_end(args); | ||
168 | ExitOnFailure(hr, "Failed to format error log string."); | 210 | ExitOnFailure(hr, "Failed to format error log string."); |
169 | 211 | ||
170 | hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); | 212 | hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); |