Package: kicad / 4.0.5+dfsg1-4

fixes/Replace-avhttp-with-libcurl.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
From: unknown <mark.roszko@gmail.com>
Date: Tue, 22 Dec 2015 15:19:00 +0100
Subject: Replace avhttp with libcurl

Some fixes:
1. Fixed an assumption somebody originally made in the plugin that
   std::string had contiguous storage. This is not specced behavior pre
   C++11 so we gamble by calling .reserve() which should give a far
   better guarantee.

2. Added copy to clipboard information for curl

3. Removed some openssl references in compiling.md

4. Renamed struct vars to be uppercase to match "public var" code style
   policy
---
 Documentation/development/compiling.md | 12 +-----------
 common/basicframe.cpp                  |  3 +++
 common/kicad_curl/kicad_curl.cpp       | 26 ++++++++++++++++++++++++++
 common/kicad_curl/kicad_curl_easy.cpp  | 26 +++++++++++++-------------
 include/kicad_curl/kicad_curl.h        |  7 +++++++
 include/kicad_curl/kicad_curl_easy.h   |  6 +++---
 pcbnew/github/CMakeLists.txt           |  2 --
 pcbnew/github/github_getliblist.cpp    |  5 +++--
 pcbnew/github/github_plugin.cpp        |  3 ++-
 9 files changed, 58 insertions(+), 32 deletions(-)

diff --git a/Documentation/development/compiling.md b/Documentation/development/compiling.md
index 90cea955..6a5ac92c 100644
--- a/Documentation/development/compiling.md
+++ b/Documentation/development/compiling.md
@@ -78,14 +78,6 @@ specific patches required to build a working Boost library.  These patches can b
 [patches folder][] in the KiCad source.  These patches are named by the platform name they should
 be applied against.
 
-## OpenSSL Secure Socket Layer Library ## {#openssl}
-
-The [OpenSSL][] library is only required when the KiCad build is configured with the Github plugin
-enabled.  See the [KiCad Build Configuration Options](#build_opts)` section for more information.
-Please note that KiCad will download and build version 1.0.1e of OpenSSL by default.  You should
-probably use the version of OpenSSL installed on your system as it will most likely be more up to
-date and contain the latest security fixes.
-
 ## GLEW OpenGL Extension Wrangler Library ## {#glew}
 
 The [OpenGL Extension Wrangler][GLEW] is an OpenGL helper library used by the KiCad graphics
@@ -299,7 +291,7 @@ the following commands:
               mingw-w64-x86_64-boost \
               mingw-w64-x86_64-cairo \
               mingw-w64-x86_64-glew \
-              mingw-w64-x86_64-openssl \
+              mingw-w64-x86_64-curl \
               mingw-w64-x86_64-wxPython \
               mingw-w64-x86_64-wxWidgets
     cd kicad-source
@@ -311,7 +303,6 @@ the following commands:
           -DCMAKE_PREFIX_PATH=/mingw64 \
           -DCMAKE_INSTALL_PREFIX=/mingw64 \
           -DDEFAULT_INSTALL_PATH=/mingw64 \
-          -DOPENSSL_ROOT_DIR=/mingw64 \
           -DKICAD_SKIP_BOOST=ON \
           -DKICAD_SCRIPTING=ON \
           -DKICAD_SCRIPTING_MODULES=ON \
@@ -408,7 +399,6 @@ Boost patches in the KiCad source [patch folder][].
 [wxWidgets]: http://wxwidgets.org/
 [patches folder]: http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/files/head:/patches/
 [Boost]: http://www.boost.org/
-[OpenSSL]: https://www.openssl.org/
 [GLEW]: http://glew.sourceforge.net/
 [GLUT]: https://www.opengl.org/resources/libraries/glut/
 [Cairo]: http://cairographics.org/
diff --git a/common/basicframe.cpp b/common/basicframe.cpp
index 46ddd550..815247d0 100644
--- a/common/basicframe.cpp
+++ b/common/basicframe.cpp
@@ -28,6 +28,7 @@
  * @brief EDA_BASE_FRAME class implementation.
  */
 
+#include <kicad_curl/kicad_curl.h> /* Include before any wx file */
 #include <wx/aboutdlg.h>
 #include <wx/fontdlg.h>
 #include <wx/clipbrd.h>
@@ -580,6 +581,8 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent&  event )
                 << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
                 << ( BOOST_VERSION % 100 ) << wxT( "\n" );
 
+    msg_version <<  KICAD_CURL::GetSimpleVersion() << wxT( "\n" );
+
     msg_version << wxT( "         USE_WX_GRAPHICS_CONTEXT=" );
 #ifdef USE_WX_GRAPHICS_CONTEXT
     msg_version << wxT( "ON\n" );
diff --git a/common/kicad_curl/kicad_curl.cpp b/common/kicad_curl/kicad_curl.cpp
index 7424eec8..0df25288 100644
--- a/common/kicad_curl/kicad_curl.cpp
+++ b/common/kicad_curl/kicad_curl.cpp
@@ -51,4 +51,30 @@ std::string KICAD_CURL::GetVersion()
 }
 
 
+std::string KICAD_CURL::GetSimpleVersion()
+{
+    curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
+
+    std::string res;
+
+    if( info->version )
+    {
+        res += "libcurl version: " + std::string(info->version);
+    }
+
+    res += " (";
+    if( info->features & CURL_VERSION_SSL )
+    {
+        res += "with SSL - ";
+        res += std::string(info->ssl_version);
+    }
+    else
+    {
+        res += "without SSL";
+    }
+    res += ")";
+
+    return res;
+}
+
 bool KICAD_CURL::m_initialized = false;
\ No newline at end of file
diff --git a/common/kicad_curl/kicad_curl_easy.cpp b/common/kicad_curl/kicad_curl_easy.cpp
index 71a410d0..4dadf043 100644
--- a/common/kicad_curl/kicad_curl_easy.cpp
+++ b/common/kicad_curl/kicad_curl_easy.cpp
@@ -43,8 +43,8 @@ KICAD_CURL_EASY::KICAD_CURL_EASY()
         THROW_IO_ERROR( "Unable to initialize CURL session" );
     }
 
-    m_Buffer.payload = (char*)malloc( 1 );
-    m_Buffer.size = 0;
+    m_Buffer.Payload = (char*)malloc( 1 );
+    m_Buffer.Size = 0;
 
     curl_easy_setopt( m_CURL, CURLOPT_WRITEFUNCTION, write_callback );
     curl_easy_setopt( m_CURL, CURLOPT_WRITEDATA, (void *)&m_Buffer );
@@ -53,7 +53,7 @@ KICAD_CURL_EASY::KICAD_CURL_EASY()
 
 KICAD_CURL_EASY::~KICAD_CURL_EASY()
 {
-    free(m_Buffer.payload);
+    free(m_Buffer.Payload);
     curl_easy_cleanup(m_CURL);
 }
 
@@ -110,27 +110,27 @@ static size_t write_callback( void *contents, size_t size, size_t nmemb, void *u
     struct KICAD_EASY_CURL_BUFFER *p = ( struct KICAD_EASY_CURL_BUFFER * ) userp;
 
     /* expand buffer */
-    p->payload = (char *) realloc( p->payload, p->size + realsize + 1 );
+    p->Payload = (char *) realloc( p->Payload, p->Size + realsize + 1 );
 
     /* check buffer */
-    if ( p->payload == NULL )
+    if ( p->Payload == NULL )
     {
         wxLogError( wxT( "Failed to expand buffer in curl_callback" ) );
 
         /* free buffer */
-        free( p->payload );
+        free( p->Payload );
 
         return -1;
     }
 
     /* copy contents to buffer */
-    memcpy( &(p->payload[p->size]), contents, realsize );
+    memcpy( &(p->Payload[p->Size]), contents, realsize );
 
     /* set new buffer size */
-    p->size += realsize;
+    p->Size += realsize;
 
     /* ensure null termination */
-    p->payload[p->size] = 0;
+    p->Payload[p->Size] = 0;
 
     /* return size */
     return realsize;
@@ -144,11 +144,11 @@ void KICAD_CURL_EASY::Perform()
         curl_easy_setopt( m_CURL, CURLOPT_HTTPHEADER, m_headers );
     }
 
-    if( m_Buffer.size > 0 )
+    if( m_Buffer.Size > 0 )
     {
-        free( m_Buffer.payload );
-        m_Buffer.payload = (char*)malloc( 1 );
-        m_Buffer.size = 0;
+        free( m_Buffer.Payload );
+        m_Buffer.Payload = (char*)malloc( 1 );
+        m_Buffer.Size = 0;
     }
 
     CURLcode res = curl_easy_perform( m_CURL );
diff --git a/include/kicad_curl/kicad_curl.h b/include/kicad_curl/kicad_curl.h
index 3639400c..ef49f92d 100644
--- a/include/kicad_curl/kicad_curl.h
+++ b/include/kicad_curl/kicad_curl.h
@@ -75,6 +75,13 @@ public:
      */
     static std::string GetVersion();
 
+    /**
+     * Function GetSimpleVersion
+     * Reports back curl version only and SSL library support
+     *
+     * @return std::string - Generated version string
+     */
+    static std::string GetSimpleVersion();
 private:
     static bool m_initialized;
 };
diff --git a/include/kicad_curl/kicad_curl_easy.h b/include/kicad_curl/kicad_curl_easy.h
index a87c3d02..2273e489 100644
--- a/include/kicad_curl/kicad_curl_easy.h
+++ b/include/kicad_curl/kicad_curl_easy.h
@@ -52,8 +52,8 @@
  */
 struct KICAD_EASY_CURL_BUFFER
 {
-    char* payload;
-    size_t size;
+    char* Payload;
+    size_t Size;
 };
 
 
@@ -142,7 +142,7 @@ public:
      * @param aArg is the argument being passed to CURL, ensure it is the right type per manual
      * @return CURLcode - CURL error code, will return CURLE_OK unless a problem was encountered
      */
-    template <typename T> CURLcode SetOption( CURLoption aOption, T aArg ) 
+    template <typename T> CURLcode SetOption( CURLoption aOption, T aArg )
     { 
         return curl_easy_setopt( m_CURL, aOption, aArg ); 
     }
diff --git a/pcbnew/github/CMakeLists.txt b/pcbnew/github/CMakeLists.txt
index bb37ebf5..c6615e48 100644
--- a/pcbnew/github/CMakeLists.txt
+++ b/pcbnew/github/CMakeLists.txt
@@ -32,8 +32,6 @@ set( GITHUB_PLUGIN_SRCS
 
 add_library( github_plugin STATIC ${GITHUB_PLUGIN_SRCS} )
 
-# No, you don't get github without boost and openssl. Boost_LIBRARIES now moved up
-# into CMakeLists.txt for pcbnew and cvpcb:
 target_link_libraries( github_plugin
     common
     )
diff --git a/pcbnew/github/github_getliblist.cpp b/pcbnew/github/github_getliblist.cpp
index baf5f7c2..6c8f8852 100644
--- a/pcbnew/github/github_getliblist.cpp
+++ b/pcbnew/github/github_getliblist.cpp
@@ -212,7 +212,7 @@ bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL,
 bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError )
 {
     KICAD_CURL_EASY kcurl;
-    
+
     wxLogDebug( wxT( "Attempting to download: " ) + aFullURLCommand );
 
     kcurl.SetURL(aFullURLCommand);
@@ -223,7 +223,8 @@ bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxStr
     try
     {
         kcurl.Perform();
-        m_image.assign(kcurl.GetBuffer()->payload, kcurl.GetBuffer()->size);
+        m_image.reserve( kcurl.GetBuffer()->Size );
+        m_image.assign( kcurl.GetBuffer()->Payload, kcurl.GetBuffer()->Size );
         return true;
     }
     catch( const IO_ERROR& ioe )
diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp
index db96ae18..321e0b76 100644
--- a/pcbnew/github/github_plugin.cpp
+++ b/pcbnew/github/github_plugin.cpp
@@ -538,7 +538,8 @@ void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR )
     try
     {
         kcurl.Perform();
-        m_zip_image.assign(kcurl.GetBuffer()->payload, kcurl.GetBuffer()->size);
+        m_zip_image.reserve( kcurl.GetBuffer()->Size );
+        m_zip_image.assign( kcurl.GetBuffer()->Payload, kcurl.GetBuffer()->Size );
     }
     catch( const IO_ERROR& ioe )
     {