LibreOffice Module ucb (master) 1
ftploaderthread.cxx
Go to the documentation of this file.
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/**************************************************************************
21 TODO
22 **************************************************************************
23
24 *************************************************************************/
25#include "ftploaderthread.hxx"
26#include "curl.hxx"
27
28using namespace ftp;
29
30
31/********************************************************************************/
32/* */
33/* cleanup function for thread specific data */
34/* */
35/********************************************************************************/
36
37extern "C" {
38
39 static int memory_write_dummy(void *,size_t,size_t,void *)
40 {
41 return 0;
42 }
43
44 static void delete_CURL(void *pData)
45 {
46 // Otherwise response for QUIT will be sent to already destroyed
47 // MemoryContainer via non-dummy memory_write function.
48 (void)curl_easy_setopt(static_cast<CURL*>(pData),
49 CURLOPT_HEADERFUNCTION,
51 curl_easy_cleanup(static_cast<CURL*>(pData));
52 }
53
54}
55
56/********************************************************************************/
57/* */
58/* Member part of FTPLoaderThread */
59/* */
60/********************************************************************************/
61
62
63FTPLoaderThread::FTPLoaderThread()
64 : m_threadKey(osl_createThreadKey(delete_CURL)) {
65}
66
67
69 osl_destroyThreadKey(m_threadKey);
70}
71
72
74 CURL* ret = static_cast<CURL*>(osl_getThreadKeyData(m_threadKey));
75 if(!ret) {
76 ret = curl_easy_init();
77 if (ret != nullptr) {
78 // Make sure curl is not internally using environment variables like
79 // "ftp_proxy":
80 if (curl_easy_setopt(ret, CURLOPT_PROXY, "") != CURLE_OK) {
81 curl_easy_cleanup(ret);
82 ret = nullptr;
83 }
84 }
85 osl_setThreadKeyData(m_threadKey, ret);
86 }
87
88 return ret;
89}
90
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void delete_CURL(void *pData)
static int memory_write_dummy(void *, size_t, size_t, void *)
std::unique_ptr< sal_Int32[]> pData
Definition of ftpcontentprovider.