| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <sal/config.h> |
| 21 |
|
| 22 |
#include <xmlsec/errorcallback.hxx> |
| 23 |
|
| 24 |
#include <rtl/ustring.hxx> |
| 25 |
#include <sal/log.hxx> |
| 26 |
#include <xmlsec/xmlsec.h> |
| 27 |
#include <xmlsec/errors.h> |
| 28 |
|
| 29 |
#ifdef _WIN32 |
| 30 |
#include <prewin.h> |
| 31 |
#include <postwin.h> |
| 32 |
#include <comphelper/windowserrorstring.hxx> |
| 33 |
#endif |
| 34 |
|
| 35 |
extern "C" { |
| 36 |
|
| 37 |
static void errorCallback(const char* file, |
| 38 |
int line, |
| 39 |
const char* func, |
| 40 |
const char* errorObject, |
| 41 |
const char* errorSubject, |
| 42 |
int reason, |
| 43 |
const char* msg) |
| 44 |
{ |
| 45 |
const char* pErrorObject = errorObject ? errorObject : ""; |
| 46 |
const char* pErrorSubject = errorSubject ? errorSubject : ""; |
| 47 |
const char* pMsg = msg ? msg : ""; |
| 48 |
OUString systemErrorString; |
| 49 |
|
| 50 |
#ifdef _WIN32 |
| 51 |
systemErrorString = " " + comphelper::WindowsErrorString(GetLastError()); |
| 52 |
#endif |
| 53 |
|
| 54 |
SAL_WARN("xmlsecurity.xmlsec", file << ":" << line << ": " << func << "() '" << pErrorObject << "' '" << pErrorSubject << "' " << reason << " '" << pMsg << "'" << systemErrorString); |
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
void setErrorRecorder() |
| 60 |
{ |
| 61 |
xmlSecErrorsSetCallback(errorCallback); |
| 62 |
} |
| 63 |
|
| 64 |
void clearErrorRecorder() |
| 65 |
{ |
| 66 |
xmlSecErrorsSetCallback(nullptr); |
| 67 |
} |
| 68 |
|
| 69 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |