Previously, WindowsErrorString and WindowsErrorStringFromHRESULT were defined in an anonymous namespace in windowserrorstring.hxx, which: 1. Made them unavailable to other translation units 2. Violate ODR by creating separate copies in each TU 3. Require workarounds to access them Changes: - Move functions to proper comphelper namespace - Keep implementations inline as they're simple utilities - Preserve all existing functionality - Update all call sites to use comphelper:: prefix This change enables proper use of these utilities across LibreOffice while maintaining current behavior and performance characteristics. Introduced in this commit: commit 94cdcaa4d8db8f03ac9a84dac54357efff3eb123 Author: Tor Lillqvist <tml@collabora.com> Date: Thu Aug 13 13:22:28 2015 +0300 Add a globally usable WindowsErrorString function Change-Id: I34df1c2b1f30c6204f107ca4792131d692203880 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183332 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <sal/config.h>
|
|
|
|
#include <xmlsec/errorcallback.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
|
#include <sal/log.hxx>
|
|
#include <xmlsec/xmlsec.h>
|
|
#include <xmlsec/errors.h>
|
|
|
|
#ifdef _WIN32
|
|
#include <prewin.h>
|
|
#include <postwin.h>
|
|
#include <comphelper/windowserrorstring.hxx>
|
|
#endif
|
|
|
|
extern "C" {
|
|
|
|
static void errorCallback(const char* file,
|
|
int line,
|
|
const char* func,
|
|
const char* errorObject,
|
|
const char* errorSubject,
|
|
int reason,
|
|
const char* msg)
|
|
{
|
|
const char* pErrorObject = errorObject ? errorObject : "";
|
|
const char* pErrorSubject = errorSubject ? errorSubject : "";
|
|
const char* pMsg = msg ? msg : "";
|
|
OUString systemErrorString;
|
|
|
|
#ifdef _WIN32
|
|
systemErrorString = " " + comphelper::WindowsErrorString(GetLastError());
|
|
#endif
|
|
|
|
SAL_WARN("xmlsecurity.xmlsec", file << ":" << line << ": " << func << "() '" << pErrorObject << "' '" << pErrorSubject << "' " << reason << " '" << pMsg << "'" << systemErrorString);
|
|
}
|
|
|
|
}
|
|
|
|
void setErrorRecorder()
|
|
{
|
|
xmlSecErrorsSetCallback(errorCallback);
|
|
}
|
|
|
|
void clearErrorRecorder()
|
|
{
|
|
xmlSecErrorsSetCallback(nullptr);
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|