KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_curl.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 Mark Roszko <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef KICAD_CURL_H_
21#define KICAD_CURL_H_
22
23/*
24 * KICAD_CURL.h must be included before wxWidgets because on Windows,
25 * wxWidgets ends up including windows.h before winsocks2.h inside curl
26 * this causes build warnings
27 * Because we are before wx, we must explicitly define we are building with unicode.
28 * wxWidgets defaults to supporting unicode now, so this should be safe.
29 */
30#if defined(_WIN32)
31 #ifndef UNICODE
32 # define UNICODE
33 #endif
34
35 #ifndef _UNICODE
36 # define _UNICODE
37 #endif
38#endif
39
40#include <kicommon.h>
41#include <curl/curl.h>
42#include <string>
43#include <shared_mutex>
44
45// CURL_EXTERN expands to dllimport on MinGW which causes gcc warnings. This really should
46// expand to nothing on MinGW.
47#if defined( __MINGW32__)
48# if defined( CURL_EXTERN )
49# undef CURL_EXTERN
50# define CURL_EXTERN
51# endif
52#endif
53
58{
59public:
67 static void Init();
68
73 static void Cleanup();
74
79 static std::shared_mutex& Mutex();
80
84 static bool IsShuttingDown();
85
92 static const char* GetVersion()
93 {
94 return curl_version();
95 }
96};
97
98#endif // KICAD_CURL_H_
Simple wrapper class to call curl_global_init and curl_global_cleanup for KiCad.
Definition kicad_curl.h:58
static void Cleanup()
Call curl_global_cleanup for the application.
static void Init()
Call curl_global_init for the application.
static bool IsShuttingDown()
Returns true if all curl operations should terminate.
static std::shared_mutex & Mutex()
Returns the mutex for shared locking when performing curl operations.
static const char * GetVersion()
Wrapper for curl_version().
Definition kicad_curl.h:92
#define KICOMMON_API
Definition kicommon.h:27