1*4e7b0f82SDamjan Jovanovic /************************************************************** 2*4e7b0f82SDamjan Jovanovic * 3*4e7b0f82SDamjan Jovanovic * Licensed to the Apache Software Foundation (ASF) under one 4*4e7b0f82SDamjan Jovanovic * or more contributor license agreements. See the NOTICE file 5*4e7b0f82SDamjan Jovanovic * distributed with this work for additional information 6*4e7b0f82SDamjan Jovanovic * regarding copyright ownership. The ASF licenses this file 7*4e7b0f82SDamjan Jovanovic * to you under the Apache License, Version 2.0 (the 8*4e7b0f82SDamjan Jovanovic * "License"); you may not use this file except in compliance 9*4e7b0f82SDamjan Jovanovic * with the License. You may obtain a copy of the License at 10*4e7b0f82SDamjan Jovanovic * 11*4e7b0f82SDamjan Jovanovic * http://www.apache.org/licenses/LICENSE-2.0 12*4e7b0f82SDamjan Jovanovic * 13*4e7b0f82SDamjan Jovanovic * Unless required by applicable law or agreed to in writing, 14*4e7b0f82SDamjan Jovanovic * software distributed under the License is distributed on an 15*4e7b0f82SDamjan Jovanovic * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*4e7b0f82SDamjan Jovanovic * KIND, either express or implied. See the License for the 17*4e7b0f82SDamjan Jovanovic * specific language governing permissions and limitations 18*4e7b0f82SDamjan Jovanovic * under the License. 19*4e7b0f82SDamjan Jovanovic * 20*4e7b0f82SDamjan Jovanovic *************************************************************/ 21*4e7b0f82SDamjan Jovanovic 22*4e7b0f82SDamjan Jovanovic 23*4e7b0f82SDamjan Jovanovic 24*4e7b0f82SDamjan Jovanovic #include "oox/helper/openssl_wrapper.hxx" 25*4e7b0f82SDamjan Jovanovic #include "rtl/ustrbuf.hxx" 26*4e7b0f82SDamjan Jovanovic 27*4e7b0f82SDamjan Jovanovic #include <openssl/err.h> 28*4e7b0f82SDamjan Jovanovic 29*4e7b0f82SDamjan Jovanovic 30*4e7b0f82SDamjan Jovanovic namespace oox { 31*4e7b0f82SDamjan Jovanovic 32*4e7b0f82SDamjan Jovanovic // ============================================================================ 33*4e7b0f82SDamjan Jovanovic 34*4e7b0f82SDamjan Jovanovic using namespace ::com::sun::star::uno; 35*4e7b0f82SDamjan Jovanovic 36*4e7b0f82SDamjan Jovanovic using ::rtl::OUString; 37*4e7b0f82SDamjan Jovanovic using ::rtl::OUStringBuffer; 38*4e7b0f82SDamjan Jovanovic 39*4e7b0f82SDamjan Jovanovic // ============================================================================ 40*4e7b0f82SDamjan Jovanovic 41*4e7b0f82SDamjan Jovanovic static int error_cb( const char *message, size_t len, void *userData ) 42*4e7b0f82SDamjan Jovanovic { 43*4e7b0f82SDamjan Jovanovic OUStringBuffer* buffer = (OUStringBuffer*) userData; 44*4e7b0f82SDamjan Jovanovic buffer->appendAscii( "\n " ); 45*4e7b0f82SDamjan Jovanovic // The message often ends in its own '\n', remove this: 46*4e7b0f82SDamjan Jovanovic if( len > 0 && message[ len - 1 ] == '\n' ) 47*4e7b0f82SDamjan Jovanovic buffer->appendAscii( message, len - 1 ); 48*4e7b0f82SDamjan Jovanovic else 49*4e7b0f82SDamjan Jovanovic buffer->appendAscii( message, len ); 50*4e7b0f82SDamjan Jovanovic return 1; 51*4e7b0f82SDamjan Jovanovic } 52*4e7b0f82SDamjan Jovanovic 53*4e7b0f82SDamjan Jovanovic void throwOpenSSLException( const char *prefix ) throw ( Exception ) 54*4e7b0f82SDamjan Jovanovic { 55*4e7b0f82SDamjan Jovanovic OUStringBuffer buffer; 56*4e7b0f82SDamjan Jovanovic buffer.appendAscii( prefix ); 57*4e7b0f82SDamjan Jovanovic ERR_print_errors_cb( error_cb, &buffer ); 58*4e7b0f82SDamjan Jovanovic throw Exception( buffer.makeStringAndClear(), Reference< XInterface >() ); 59*4e7b0f82SDamjan Jovanovic } 60*4e7b0f82SDamjan Jovanovic 61*4e7b0f82SDamjan Jovanovic // ============================================================================ 62*4e7b0f82SDamjan Jovanovic 63*4e7b0f82SDamjan Jovanovic } // namespace oox 64