├── .gitignore ├── README.md ├── curl_multi.sln └── curl_multi ├── HttpTask.cpp ├── HttpTask.h ├── ReadMe.txt ├── Resource.h ├── SkyChaserHttp.cpp ├── SkyChaserHttp.h ├── SkyMultiHttp.cpp ├── SkyMultiHttp.h ├── curl_multi.h ├── curl_multi.rc ├── curl_multi.vcxproj ├── curl_multi.vcxproj.filters ├── libcurl ├── curl.h ├── curlbuild.h ├── curlrules.h ├── curlver.h ├── easy.h ├── lib │ ├── libcurl.lib │ ├── libcurld.lib │ ├── libeay32.lib │ ├── libeay32d.lib │ ├── ssleay32.lib │ ├── ssleay32d.lib │ ├── zlib.lib │ └── zlibd.lib ├── mprintf.h ├── multi.h ├── stdcheaders.h ├── typecheck-gcc.h └── zlib │ ├── zconf.h │ └── zlib.h ├── libuv ├── include │ ├── android-ifaddrs.h │ ├── pthread-barrier.h │ ├── stdint-msvc2008.h │ ├── tree.h │ ├── uv-aix.h │ ├── uv-bsd.h │ ├── uv-darwin.h │ ├── uv-errno.h │ ├── uv-linux.h │ ├── uv-os390.h │ ├── uv-posix.h │ ├── uv-sunos.h │ ├── uv-threadpool.h │ ├── uv-unix.h │ ├── uv-version.h │ ├── uv-win.h │ └── uv.h └── lib │ └── libuv.lib ├── main.cpp ├── scCookie.txt ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── test.cpp ├── use_curl_multi.cpp └── use_curl_multi.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.[oa] 2 | *.~ 3 | *.swp 4 | *.out 5 | *.in 6 | *.o 7 | 8 | ################# 9 | ## Eclipse 10 | ################# 11 | 12 | *.pydevproject 13 | .project 14 | .metadata 15 | bin/ 16 | tmp/ 17 | *.tmp 18 | *.bak 19 | *.swp 20 | *~.nib 21 | local.properties 22 | .classpath 23 | .settings/ 24 | .loadpath 25 | 26 | # External tool builders 27 | .externalToolBuilders/ 28 | 29 | # Locally stored "Eclipse launch configurations" 30 | *.launch 31 | 32 | # CDT-specific 33 | .cproject 34 | 35 | # PDT-specific 36 | .buildpath 37 | 38 | 39 | ################# 40 | ## Visual Studio 41 | ################# 42 | 43 | ## Ignore Visual Studio temporary files, build results, and 44 | ## files generated by popular Visual Studio add-ons. 45 | 46 | # User-specific files 47 | *.suo 48 | *.user 49 | *.sln.docstates 50 | 51 | # Build results 52 | [Dd]ebug/ 53 | [Rr]elease/ 54 | *_i.c 55 | *_p.c 56 | *.ilk 57 | *.meta 58 | *.obj 59 | *.pch 60 | *.pdb 61 | *.pgc 62 | *.pgd 63 | *.rsp 64 | *.sbr 65 | *.tlb 66 | *.tli 67 | *.tlh 68 | *.tmp 69 | *.vspscc 70 | .builds 71 | *.dotCover 72 | 73 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 74 | #packages/ 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opensdf 81 | *.sdf 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | 87 | # ReSharper is a .NET coding add-in 88 | _ReSharper* 89 | 90 | # Installshield output folder 91 | [Ee]xpress 92 | 93 | # DocProject is a documentation generator add-in 94 | DocProject/buildhelp/ 95 | DocProject/Help/*.HxT 96 | DocProject/Help/*.HxC 97 | DocProject/Help/*.hhc 98 | DocProject/Help/*.hhk 99 | DocProject/Help/*.hhp 100 | DocProject/Help/Html2 101 | DocProject/Help/html 102 | 103 | # Click-Once directory 104 | publish 105 | 106 | # Others 107 | [Bb]in 108 | [Oo]bj 109 | sql 110 | TestResults 111 | *.Cache 112 | ClientBin 113 | stylecop.* 114 | ~$* 115 | *.dbmdl 116 | Generated_Code #added for RIA/Silverlight projects 117 | 118 | # Backup & report files from converting an old project file to a newer 119 | # Visual Studio version. Backup files are not needed, because we have git ;-) 120 | _UpgradeReport_Files/ 121 | Backup*/ 122 | UpgradeLog*.XML 123 | 124 | 125 | 126 | ############ 127 | ## Windows 128 | ############ 129 | 130 | # Windows image file caches 131 | Thumbs.db 132 | 133 | # Folder config file 134 | Desktop.ini 135 | 136 | 137 | ############# 138 | ## Python 139 | ############# 140 | 141 | *.py[co] 142 | 143 | # Packages 144 | *.egg 145 | *.egg-info 146 | dist 147 | build 148 | eggs 149 | parts 150 | bin 151 | var 152 | sdist 153 | develop-eggs 154 | .installed.cfg 155 | 156 | # Installer logs 157 | pip-log.txt 158 | 159 | # Unit test / coverage reports 160 | .coverage 161 | .tox 162 | 163 | #Translations 164 | *.mo 165 | 166 | #Mr Developer 167 | .mr.developer.cfg 168 | 169 | # Mac crap 170 | .DS_Store 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 封装libcurl+libuv实现multi异步高效http请求 2 | 3 | 4 | > 关于libcurl+libuv实现异步http请求的简单例子可以参考:http://blog.csdn.net/lijinqi1987/article/details/53996129

开发环境:win7, vs2013 5 | 6 | 7 | 8 | ## libuv使用流程 9 | 10 | > 主要参考上面文章中的代码 11 | 12 | 1. 获取默认事件循环句柄`uv_loop_t loop = uv_default_loop();` 13 | 14 | 2. 初始化定时器`uv_timer_init(loop, &timeout);` 15 | 16 | 3. 设置回调函数 17 | 18 | 4. 开始循环`uv_run(loop, UV_RUN_DEFAULT);` 19 | 20 | ## libuv和libcurl的mutil接口结合 21 | 22 | > 主要参考上面文章中的代码 23 | 24 | 1. 获得`curl multi`句柄`curl_handle = curl_multi_init();` 25 | 26 | 2. 设置回调 27 | 28 | ```cpp 29 | //调用handle_socket回调函数,传入新建的sockfd,根据传入的action状态添加到相应的事件管理器,如封装epoll的libev或libevent。 30 | curl_multi_setopt(curl_handle, CURLMOPT_SOCKETFUNCTION, handle_socket); 31 | /*当使用curl_multi_add_handle(g->multi, conn->easy)添加请求时会回调start_timeout,然后调用 32 | curl_multi_socket_action(curl_handle, CURL_SOCKET_TIMEOUT, 0, &running_handles)初始化请求并得到一个socket(fd)*/ 33 | curl_multi_setopt(curl_handle, CURLMOPT_TIMERFUNCTION, start_timeout); 34 | ``` 35 | 36 | 3. 循环结束后清理环境`curl_multi_cleanup(curl_handle);` 37 | 38 | 39 | ## 封装 40 | 41 | 1. 对于`curl multi`接口的http请求而言,除了不是主动请求,其他使用方式和`easy`接口完全一致,因此根据需要修改了以前的`CSkyChaserHttp`类,仅为构造增加了一个默认参,在使用`multi`接口时不主动进行http请求 42 | 43 | 2. 对于`libuv`和`libcurl`配合使用的部分,由于除了完成请求后的回调需要自己控制,其他的都是固定的套路,因此封装了一个`CSkyMultiHttp`类,在构造时将回调函数传进去,然后调用`Init()`方法来初始化,然后通过`curl_multi_add_handle(CSkyMultiHttp::m_curl_handle, http_curl_handle);`来添加事件,最后通过`loop()`方法来开始事件循环 44 | 45 | 3. 最后再封装了一个`CHttpTask`类,用来管理所有的`http_curl_handle`和任务事件,从而实现连续的http请求动作,通过`AddTask()`方法来添加最初的事件任务,再通过`TaskDoneProc(...)`方法来处理一个请求完成后的动作,主要是添加下一个请求到事件循环中 46 | 47 | ## 效果 48 | 49 | 对一个小型网站进行注册测试: 50 | 51 | - 开1000个并发连接,一共1万×5次请求(不包括30X重定向产生的请求),速度局限于对方服务器和网速,显得比较慢,而且这么多并发,直接导致对方服务器无响应了,失败几率很高,并且在测试期间,通过浏览器很难访问这个网站,而本机CPU占用率很低,在这种情况下无法测出性能的极限 52 | 53 | ## vs2013环境下编译libuv 54 | 55 | [https://kevins.pro/bulid_libuv_with_vs2013.html](https://kevins.pro/bulid_libuv_with_vs2013.html) -------------------------------------------------------------------------------- /curl_multi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "curl_multi", "curl_multi\curl_multi.vcxproj", "{EAF8BFB2-40D3-4C91-80CF-8E9F03703555}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EAF8BFB2-40D3-4C91-80CF-8E9F03703555}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {EAF8BFB2-40D3-4C91-80CF-8E9F03703555}.Debug|Win32.Build.0 = Debug|Win32 16 | {EAF8BFB2-40D3-4C91-80CF-8E9F03703555}.Release|Win32.ActiveCfg = Release|Win32 17 | {EAF8BFB2-40D3-4C91-80CF-8E9F03703555}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /curl_multi/HttpTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/HttpTask.cpp -------------------------------------------------------------------------------- /curl_multi/HttpTask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SkyMultiHttp.h" 3 | #include 4 | #include 5 | using std::string; 6 | using std::map; 7 | 8 | #define TASK_VIST_REG 0 9 | #define TASK_POST_REG 1 10 | #define TASK_POST_LOGIN 2 11 | #define TASK_VIST_ROOT 3 12 | #define TASK_GET_LOGOUT 4 13 | 14 | #define START_TASK_NUM 10 15 | #define ALL_TASK_NUM 10 16 | 17 | typedef struct _HttpInfo 18 | { 19 | CSkyChaserHttp* pHttp; 20 | string* pstrRet; 21 | int nTask; 22 | int nTaskLevel; 23 | char* szBuff; 24 | inline _HttpInfo() 25 | : pHttp(NULL) 26 | , pstrRet(NULL) 27 | , nTask(0) 28 | , nTaskLevel(0) 29 | , szBuff(NULL) 30 | { 31 | pHttp = new CSkyChaserHttp(true); 32 | pstrRet = new string; 33 | szBuff = new char[ MAXBYTE ]; 34 | } 35 | 36 | inline ~_HttpInfo() 37 | { 38 | if(pHttp != NULL) 39 | { 40 | // curl_easy_cleanup(pHttp->get_handle()); 41 | delete pHttp; 42 | } 43 | if(pstrRet != NULL) 44 | { 45 | delete pstrRet; 46 | } 47 | if(szBuff != NULL) 48 | { 49 | delete szBuff; 50 | } 51 | } 52 | } HttpInfo; 53 | 54 | 55 | typedef map MapType; 56 | 57 | class CHttpTask 58 | { 59 | public: 60 | CHttpTask(); 61 | ~CHttpTask(); 62 | BOOL Init(); 63 | static void TaskDoneProc(CURL* handle); 64 | void Start(); 65 | static void SetEnv(char* szRegName , int nConcurrent , int nCount); 66 | 67 | protected: 68 | static MapType m_mapTask; 69 | CSkyMultiHttp m_multi; 70 | void InitFloder(char* szFloder); 71 | void SetHttpHeader(CSkyChaserHttp& http , int num); 72 | void AddTask(); 73 | static CRITICAL_SECTION m_csLock; 74 | static int m_nTask; 75 | static char* m_szRegName; 76 | static int m_nConcurrent; 77 | static int m_nCount; 78 | }; 79 | 80 | -------------------------------------------------------------------------------- /curl_multi/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:curl_multi 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 curl_multi 应用程序。 6 | 7 | 本文件概要介绍组成 curl_multi 应用程序的每个文件的内容。 8 | 9 | 10 | curl_multi.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | curl_multi.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | curl_multi.cpp 17 | 这是主应用程序源文件。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 应用程序向导创建了下列资源: 21 | 22 | curl_multi.rc 23 | 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。 24 | 25 | Resource.h 26 | 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | 其他标准文件: 30 | 31 | StdAfx.h, StdAfx.cpp 32 | 这些文件用于生成名为 curl_multi.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | 其他注释: 36 | 37 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 38 | 39 | ///////////////////////////////////////////////////////////////////////////// 40 | -------------------------------------------------------------------------------- /curl_multi/Resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/Resource.h -------------------------------------------------------------------------------- /curl_multi/SkyChaserHttp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/SkyChaserHttp.cpp -------------------------------------------------------------------------------- /curl_multi/SkyChaserHttp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/SkyChaserHttp.h -------------------------------------------------------------------------------- /curl_multi/SkyMultiHttp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/SkyMultiHttp.cpp -------------------------------------------------------------------------------- /curl_multi/SkyMultiHttp.h: -------------------------------------------------------------------------------- 1 | #include "uv.h" 2 | #include "SkyChaserHttp.h" 3 | #include "curl.h" 4 | #include "curl_multi.h" 5 | 6 | typedef void(*done_proc)(CURL* handle); 7 | 8 | typedef struct curl_context_s { 9 | uv_poll_t poll_handle; 10 | curl_socket_t sockfd; 11 | } curl_context_t; 12 | 13 | class CSkyMultiHttp 14 | { 15 | public: 16 | CSkyMultiHttp(done_proc proc); 17 | ~CSkyMultiHttp(); 18 | BOOL Init(); 19 | 20 | curl_context_t *create_curl_context(curl_socket_t sockfd); 21 | void destroy_curl_context(curl_context_t *context); 22 | void check_multi_info(void); 23 | static void curl_close_cb(uv_handle_t *handle); 24 | static void curl_perform(uv_poll_t *req, int status, int events); 25 | static void on_timeout(uv_timer_t *req); 26 | static void start_timeout(CURLM *multi, long timeout_ms, void *userp); 27 | static int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp, void *socketp); 28 | void loop(); 29 | 30 | static uv_loop_t * m_loop; 31 | static CURLM * m_curl_handle; 32 | static uv_timer_t m_timeout; 33 | 34 | protected: 35 | static CSkyMultiHttp* m_obj; 36 | static done_proc m_done_proc; 37 | }; -------------------------------------------------------------------------------- /curl_multi/curl_multi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | 5 | #pragma comment(lib, "libuv.lib") 6 | #pragma comment(lib, "Iphlpapi.lib") 7 | #pragma comment(lib, "Psapi.lib") 8 | #pragma comment(lib, "Userenv.lib") 9 | -------------------------------------------------------------------------------- /curl_multi/curl_multi.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/curl_multi.rc -------------------------------------------------------------------------------- /curl_multi/curl_multi.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {EAF8BFB2-40D3-4C91-80CF-8E9F03703555} 15 | Win32Proj 16 | curl_multi 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | Dynamic 25 | 26 | 27 | Application 28 | false 29 | v120 30 | true 31 | Unicode 32 | Dynamic 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | .\libcurl;.\libuv\include;$(IncludePath) 47 | .\libuv\lib;.\libcurl\lib;$(LibraryPath) 48 | 49 | 50 | false 51 | .\libuv\include;.\libcurl;$(IncludePath) 52 | .\libuv\lib;.\libcurl\lib;$(LibraryPath) 53 | 54 | 55 | 56 | NotUsing 57 | Level3 58 | Disabled 59 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 60 | true 61 | MultiThreadedDebugDLL 62 | 63 | 64 | Console 65 | true 66 | libcmt.lib;%(IgnoreSpecificDefaultLibraries) 67 | 68 | 69 | 70 | 71 | Level3 72 | NotUsing 73 | MaxSpeed 74 | true 75 | true 76 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 77 | true 78 | 79 | 80 | Console 81 | true 82 | true 83 | true 84 | libcmt.lib;%(IgnoreSpecificDefaultLibraries) 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | Create 105 | Create 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /curl_multi/curl_multi.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 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 | -------------------------------------------------------------------------------- /curl_multi/libcurl/curlbuild.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLBUILD_H 2 | #define __CURL_CURLBUILD_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* ================================================================ */ 26 | /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ 27 | /* ================================================================ */ 28 | 29 | /* 30 | * NOTE 1: 31 | * ------- 32 | * 33 | * See file include/curl/curlbuild.h.in, run configure, and forget 34 | * that this file exists it is only used for non-configure systems. 35 | * But you can keep reading if you want ;-) 36 | * 37 | */ 38 | 39 | /* ================================================================ */ 40 | /* NOTES FOR NON-CONFIGURE SYSTEMS */ 41 | /* ================================================================ */ 42 | 43 | /* 44 | * NOTE 1: 45 | * ------- 46 | * 47 | * Nothing in this file is intended to be modified or adjusted by the 48 | * curl library user nor by the curl library builder. 49 | * 50 | * If you think that something actually needs to be changed, adjusted 51 | * or fixed in this file, then, report it on the libcurl development 52 | * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/ 53 | * 54 | * Try to keep one section per platform, compiler and architecture, 55 | * otherwise, if an existing section is reused for a different one and 56 | * later on the original is adjusted, probably the piggybacking one can 57 | * be adversely changed. 58 | * 59 | * In order to differentiate between platforms/compilers/architectures 60 | * use only compiler built in predefined preprocessor symbols. 61 | * 62 | * This header file shall only export symbols which are 'curl' or 'CURL' 63 | * prefixed, otherwise public name space would be polluted. 64 | * 65 | * NOTE 2: 66 | * ------- 67 | * 68 | * For any given platform/compiler curl_off_t must be typedef'ed to a 69 | * 64-bit wide signed integral data type. The width of this data type 70 | * must remain constant and independent of any possible large file 71 | * support settings. 72 | * 73 | * As an exception to the above, curl_off_t shall be typedef'ed to a 74 | * 32-bit wide signed integral data type if there is no 64-bit type. 75 | * 76 | * As a general rule, curl_off_t shall not be mapped to off_t. This 77 | * rule shall only be violated if off_t is the only 64-bit data type 78 | * available and the size of off_t is independent of large file support 79 | * settings. Keep your build on the safe side avoiding an off_t gating. 80 | * If you have a 64-bit off_t then take for sure that another 64-bit 81 | * data type exists, dig deeper and you will find it. 82 | * 83 | * NOTE 3: 84 | * ------- 85 | * 86 | * Right now you might be staring at file include/curl/curlbuild.h.dist or 87 | * at file include/curl/curlbuild.h, this is due to the following reason: 88 | * file include/curl/curlbuild.h.dist is renamed to include/curl/curlbuild.h 89 | * when the libcurl source code distribution archive file is created. 90 | * 91 | * File include/curl/curlbuild.h.dist is not included in the distribution 92 | * archive. File include/curl/curlbuild.h is not present in the git tree. 93 | * 94 | * The distributed include/curl/curlbuild.h file is only intended to be used 95 | * on systems which can not run the also distributed configure script. 96 | * 97 | * On systems capable of running the configure script, the configure process 98 | * will overwrite the distributed include/curl/curlbuild.h file with one that 99 | * is suitable and specific to the library being configured and built, which 100 | * is generated from the include/curl/curlbuild.h.in template file. 101 | * 102 | * If you check out from git on a non-configure platform, you must run the 103 | * appropriate buildconf* script to set up curlbuild.h and other local files. 104 | * 105 | */ 106 | 107 | /* ================================================================ */ 108 | /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ 109 | /* ================================================================ */ 110 | 111 | #ifdef CURL_SIZEOF_LONG 112 | # error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" 113 | Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined 114 | #endif 115 | 116 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 117 | # error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 118 | Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined 119 | #endif 120 | 121 | #ifdef CURL_SIZEOF_CURL_SOCKLEN_T 122 | # error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 123 | Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined 124 | #endif 125 | 126 | #ifdef CURL_TYPEOF_CURL_OFF_T 127 | # error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 128 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined 129 | #endif 130 | 131 | #ifdef CURL_FORMAT_CURL_OFF_T 132 | # error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" 133 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined 134 | #endif 135 | 136 | #ifdef CURL_FORMAT_CURL_OFF_TU 137 | # error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" 138 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined 139 | #endif 140 | 141 | #ifdef CURL_FORMAT_OFF_T 142 | # error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" 143 | Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined 144 | #endif 145 | 146 | #ifdef CURL_SIZEOF_CURL_OFF_T 147 | # error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 148 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined 149 | #endif 150 | 151 | #ifdef CURL_SUFFIX_CURL_OFF_T 152 | # error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" 153 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined 154 | #endif 155 | 156 | #ifdef CURL_SUFFIX_CURL_OFF_TU 157 | # error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" 158 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined 159 | #endif 160 | 161 | /* ================================================================ */ 162 | /* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ 163 | /* ================================================================ */ 164 | 165 | #if defined(__DJGPP__) || defined(__GO32__) 166 | # if defined(__DJGPP__) && (__DJGPP__ > 1) 167 | # define CURL_SIZEOF_LONG 4 168 | # define CURL_TYPEOF_CURL_OFF_T long long 169 | # define CURL_FORMAT_CURL_OFF_T "lld" 170 | # define CURL_FORMAT_CURL_OFF_TU "llu" 171 | # define CURL_FORMAT_OFF_T "%lld" 172 | # define CURL_SIZEOF_CURL_OFF_T 8 173 | # define CURL_SUFFIX_CURL_OFF_T LL 174 | # define CURL_SUFFIX_CURL_OFF_TU ULL 175 | # else 176 | # define CURL_SIZEOF_LONG 4 177 | # define CURL_TYPEOF_CURL_OFF_T long 178 | # define CURL_FORMAT_CURL_OFF_T "ld" 179 | # define CURL_FORMAT_CURL_OFF_TU "lu" 180 | # define CURL_FORMAT_OFF_T "%ld" 181 | # define CURL_SIZEOF_CURL_OFF_T 4 182 | # define CURL_SUFFIX_CURL_OFF_T L 183 | # define CURL_SUFFIX_CURL_OFF_TU UL 184 | # endif 185 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 186 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 187 | 188 | #elif defined(__SALFORDC__) 189 | # define CURL_SIZEOF_LONG 4 190 | # define CURL_TYPEOF_CURL_OFF_T long 191 | # define CURL_FORMAT_CURL_OFF_T "ld" 192 | # define CURL_FORMAT_CURL_OFF_TU "lu" 193 | # define CURL_FORMAT_OFF_T "%ld" 194 | # define CURL_SIZEOF_CURL_OFF_T 4 195 | # define CURL_SUFFIX_CURL_OFF_T L 196 | # define CURL_SUFFIX_CURL_OFF_TU UL 197 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 198 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 199 | 200 | #elif defined(__BORLANDC__) 201 | # if (__BORLANDC__ < 0x520) 202 | # define CURL_SIZEOF_LONG 4 203 | # define CURL_TYPEOF_CURL_OFF_T long 204 | # define CURL_FORMAT_CURL_OFF_T "ld" 205 | # define CURL_FORMAT_CURL_OFF_TU "lu" 206 | # define CURL_FORMAT_OFF_T "%ld" 207 | # define CURL_SIZEOF_CURL_OFF_T 4 208 | # define CURL_SUFFIX_CURL_OFF_T L 209 | # define CURL_SUFFIX_CURL_OFF_TU UL 210 | # else 211 | # define CURL_SIZEOF_LONG 4 212 | # define CURL_TYPEOF_CURL_OFF_T __int64 213 | # define CURL_FORMAT_CURL_OFF_T "I64d" 214 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 215 | # define CURL_FORMAT_OFF_T "%I64d" 216 | # define CURL_SIZEOF_CURL_OFF_T 8 217 | # define CURL_SUFFIX_CURL_OFF_T i64 218 | # define CURL_SUFFIX_CURL_OFF_TU ui64 219 | # endif 220 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 221 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 222 | 223 | #elif defined(__TURBOC__) 224 | # define CURL_SIZEOF_LONG 4 225 | # define CURL_TYPEOF_CURL_OFF_T long 226 | # define CURL_FORMAT_CURL_OFF_T "ld" 227 | # define CURL_FORMAT_CURL_OFF_TU "lu" 228 | # define CURL_FORMAT_OFF_T "%ld" 229 | # define CURL_SIZEOF_CURL_OFF_T 4 230 | # define CURL_SUFFIX_CURL_OFF_T L 231 | # define CURL_SUFFIX_CURL_OFF_TU UL 232 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 233 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 234 | 235 | #elif defined(__WATCOMC__) 236 | # if defined(__386__) 237 | # define CURL_SIZEOF_LONG 4 238 | # define CURL_TYPEOF_CURL_OFF_T __int64 239 | # define CURL_FORMAT_CURL_OFF_T "I64d" 240 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 241 | # define CURL_FORMAT_OFF_T "%I64d" 242 | # define CURL_SIZEOF_CURL_OFF_T 8 243 | # define CURL_SUFFIX_CURL_OFF_T i64 244 | # define CURL_SUFFIX_CURL_OFF_TU ui64 245 | # else 246 | # define CURL_SIZEOF_LONG 4 247 | # define CURL_TYPEOF_CURL_OFF_T long 248 | # define CURL_FORMAT_CURL_OFF_T "ld" 249 | # define CURL_FORMAT_CURL_OFF_TU "lu" 250 | # define CURL_FORMAT_OFF_T "%ld" 251 | # define CURL_SIZEOF_CURL_OFF_T 4 252 | # define CURL_SUFFIX_CURL_OFF_T L 253 | # define CURL_SUFFIX_CURL_OFF_TU UL 254 | # endif 255 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 256 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 257 | 258 | #elif defined(__POCC__) 259 | # if (__POCC__ < 280) 260 | # define CURL_SIZEOF_LONG 4 261 | # define CURL_TYPEOF_CURL_OFF_T long 262 | # define CURL_FORMAT_CURL_OFF_T "ld" 263 | # define CURL_FORMAT_CURL_OFF_TU "lu" 264 | # define CURL_FORMAT_OFF_T "%ld" 265 | # define CURL_SIZEOF_CURL_OFF_T 4 266 | # define CURL_SUFFIX_CURL_OFF_T L 267 | # define CURL_SUFFIX_CURL_OFF_TU UL 268 | # elif defined(_MSC_VER) 269 | # define CURL_SIZEOF_LONG 4 270 | # define CURL_TYPEOF_CURL_OFF_T __int64 271 | # define CURL_FORMAT_CURL_OFF_T "I64d" 272 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 273 | # define CURL_FORMAT_OFF_T "%I64d" 274 | # define CURL_SIZEOF_CURL_OFF_T 8 275 | # define CURL_SUFFIX_CURL_OFF_T i64 276 | # define CURL_SUFFIX_CURL_OFF_TU ui64 277 | # else 278 | # define CURL_SIZEOF_LONG 4 279 | # define CURL_TYPEOF_CURL_OFF_T long long 280 | # define CURL_FORMAT_CURL_OFF_T "lld" 281 | # define CURL_FORMAT_CURL_OFF_TU "llu" 282 | # define CURL_FORMAT_OFF_T "%lld" 283 | # define CURL_SIZEOF_CURL_OFF_T 8 284 | # define CURL_SUFFIX_CURL_OFF_T LL 285 | # define CURL_SUFFIX_CURL_OFF_TU ULL 286 | # endif 287 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 288 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 289 | 290 | #elif defined(__LCC__) 291 | # define CURL_SIZEOF_LONG 4 292 | # define CURL_TYPEOF_CURL_OFF_T long 293 | # define CURL_FORMAT_CURL_OFF_T "ld" 294 | # define CURL_FORMAT_CURL_OFF_TU "lu" 295 | # define CURL_FORMAT_OFF_T "%ld" 296 | # define CURL_SIZEOF_CURL_OFF_T 4 297 | # define CURL_SUFFIX_CURL_OFF_T L 298 | # define CURL_SUFFIX_CURL_OFF_TU UL 299 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 300 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 301 | 302 | #elif defined(__SYMBIAN32__) 303 | # if defined(__EABI__) /* Treat all ARM compilers equally */ 304 | # define CURL_SIZEOF_LONG 4 305 | # define CURL_TYPEOF_CURL_OFF_T long long 306 | # define CURL_FORMAT_CURL_OFF_T "lld" 307 | # define CURL_FORMAT_CURL_OFF_TU "llu" 308 | # define CURL_FORMAT_OFF_T "%lld" 309 | # define CURL_SIZEOF_CURL_OFF_T 8 310 | # define CURL_SUFFIX_CURL_OFF_T LL 311 | # define CURL_SUFFIX_CURL_OFF_TU ULL 312 | # elif defined(__CW32__) 313 | # pragma longlong on 314 | # define CURL_SIZEOF_LONG 4 315 | # define CURL_TYPEOF_CURL_OFF_T long long 316 | # define CURL_FORMAT_CURL_OFF_T "lld" 317 | # define CURL_FORMAT_CURL_OFF_TU "llu" 318 | # define CURL_FORMAT_OFF_T "%lld" 319 | # define CURL_SIZEOF_CURL_OFF_T 8 320 | # define CURL_SUFFIX_CURL_OFF_T LL 321 | # define CURL_SUFFIX_CURL_OFF_TU ULL 322 | # elif defined(__VC32__) 323 | # define CURL_SIZEOF_LONG 4 324 | # define CURL_TYPEOF_CURL_OFF_T __int64 325 | # define CURL_FORMAT_CURL_OFF_T "lld" 326 | # define CURL_FORMAT_CURL_OFF_TU "llu" 327 | # define CURL_FORMAT_OFF_T "%lld" 328 | # define CURL_SIZEOF_CURL_OFF_T 8 329 | # define CURL_SUFFIX_CURL_OFF_T LL 330 | # define CURL_SUFFIX_CURL_OFF_TU ULL 331 | # endif 332 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int 333 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 334 | 335 | #elif defined(__MWERKS__) 336 | # define CURL_SIZEOF_LONG 4 337 | # define CURL_TYPEOF_CURL_OFF_T long long 338 | # define CURL_FORMAT_CURL_OFF_T "lld" 339 | # define CURL_FORMAT_CURL_OFF_TU "llu" 340 | # define CURL_FORMAT_OFF_T "%lld" 341 | # define CURL_SIZEOF_CURL_OFF_T 8 342 | # define CURL_SUFFIX_CURL_OFF_T LL 343 | # define CURL_SUFFIX_CURL_OFF_TU ULL 344 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 345 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 346 | 347 | #elif defined(_WIN32_WCE) 348 | # define CURL_SIZEOF_LONG 4 349 | # define CURL_TYPEOF_CURL_OFF_T __int64 350 | # define CURL_FORMAT_CURL_OFF_T "I64d" 351 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 352 | # define CURL_FORMAT_OFF_T "%I64d" 353 | # define CURL_SIZEOF_CURL_OFF_T 8 354 | # define CURL_SUFFIX_CURL_OFF_T i64 355 | # define CURL_SUFFIX_CURL_OFF_TU ui64 356 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 357 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 358 | 359 | #elif defined(__MINGW32__) 360 | # define CURL_SIZEOF_LONG 4 361 | # define CURL_TYPEOF_CURL_OFF_T long long 362 | # define CURL_FORMAT_CURL_OFF_T "I64d" 363 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 364 | # define CURL_FORMAT_OFF_T "%I64d" 365 | # define CURL_SIZEOF_CURL_OFF_T 8 366 | # define CURL_SUFFIX_CURL_OFF_T LL 367 | # define CURL_SUFFIX_CURL_OFF_TU ULL 368 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 369 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 370 | 371 | #elif defined(__VMS) 372 | # if defined(__VAX) 373 | # define CURL_SIZEOF_LONG 4 374 | # define CURL_TYPEOF_CURL_OFF_T long 375 | # define CURL_FORMAT_CURL_OFF_T "ld" 376 | # define CURL_FORMAT_CURL_OFF_TU "lu" 377 | # define CURL_FORMAT_OFF_T "%ld" 378 | # define CURL_SIZEOF_CURL_OFF_T 4 379 | # define CURL_SUFFIX_CURL_OFF_T L 380 | # define CURL_SUFFIX_CURL_OFF_TU UL 381 | # else 382 | # define CURL_SIZEOF_LONG 4 383 | # define CURL_TYPEOF_CURL_OFF_T long long 384 | # define CURL_FORMAT_CURL_OFF_T "lld" 385 | # define CURL_FORMAT_CURL_OFF_TU "llu" 386 | # define CURL_FORMAT_OFF_T "%lld" 387 | # define CURL_SIZEOF_CURL_OFF_T 8 388 | # define CURL_SUFFIX_CURL_OFF_T LL 389 | # define CURL_SUFFIX_CURL_OFF_TU ULL 390 | # endif 391 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int 392 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 393 | 394 | #elif defined(__OS400__) 395 | # if defined(__ILEC400__) 396 | # define CURL_SIZEOF_LONG 4 397 | # define CURL_TYPEOF_CURL_OFF_T long long 398 | # define CURL_FORMAT_CURL_OFF_T "lld" 399 | # define CURL_FORMAT_CURL_OFF_TU "llu" 400 | # define CURL_FORMAT_OFF_T "%lld" 401 | # define CURL_SIZEOF_CURL_OFF_T 8 402 | # define CURL_SUFFIX_CURL_OFF_T LL 403 | # define CURL_SUFFIX_CURL_OFF_TU ULL 404 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 405 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 406 | # define CURL_PULL_SYS_TYPES_H 1 407 | # define CURL_PULL_SYS_SOCKET_H 1 408 | # endif 409 | 410 | #elif defined(__MVS__) 411 | # if defined(__IBMC__) || defined(__IBMCPP__) 412 | # if defined(_ILP32) 413 | # define CURL_SIZEOF_LONG 4 414 | # elif defined(_LP64) 415 | # define CURL_SIZEOF_LONG 8 416 | # endif 417 | # if defined(_LONG_LONG) 418 | # define CURL_TYPEOF_CURL_OFF_T long long 419 | # define CURL_FORMAT_CURL_OFF_T "lld" 420 | # define CURL_FORMAT_CURL_OFF_TU "llu" 421 | # define CURL_FORMAT_OFF_T "%lld" 422 | # define CURL_SIZEOF_CURL_OFF_T 8 423 | # define CURL_SUFFIX_CURL_OFF_T LL 424 | # define CURL_SUFFIX_CURL_OFF_TU ULL 425 | # elif defined(_LP64) 426 | # define CURL_TYPEOF_CURL_OFF_T long 427 | # define CURL_FORMAT_CURL_OFF_T "ld" 428 | # define CURL_FORMAT_CURL_OFF_TU "lu" 429 | # define CURL_FORMAT_OFF_T "%ld" 430 | # define CURL_SIZEOF_CURL_OFF_T 8 431 | # define CURL_SUFFIX_CURL_OFF_T L 432 | # define CURL_SUFFIX_CURL_OFF_TU UL 433 | # else 434 | # define CURL_TYPEOF_CURL_OFF_T long 435 | # define CURL_FORMAT_CURL_OFF_T "ld" 436 | # define CURL_FORMAT_CURL_OFF_TU "lu" 437 | # define CURL_FORMAT_OFF_T "%ld" 438 | # define CURL_SIZEOF_CURL_OFF_T 4 439 | # define CURL_SUFFIX_CURL_OFF_T L 440 | # define CURL_SUFFIX_CURL_OFF_TU UL 441 | # endif 442 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 443 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 444 | # define CURL_PULL_SYS_TYPES_H 1 445 | # define CURL_PULL_SYS_SOCKET_H 1 446 | # endif 447 | 448 | #elif defined(__370__) 449 | # if defined(__IBMC__) || defined(__IBMCPP__) 450 | # if defined(_ILP32) 451 | # define CURL_SIZEOF_LONG 4 452 | # elif defined(_LP64) 453 | # define CURL_SIZEOF_LONG 8 454 | # endif 455 | # if defined(_LONG_LONG) 456 | # define CURL_TYPEOF_CURL_OFF_T long long 457 | # define CURL_FORMAT_CURL_OFF_T "lld" 458 | # define CURL_FORMAT_CURL_OFF_TU "llu" 459 | # define CURL_FORMAT_OFF_T "%lld" 460 | # define CURL_SIZEOF_CURL_OFF_T 8 461 | # define CURL_SUFFIX_CURL_OFF_T LL 462 | # define CURL_SUFFIX_CURL_OFF_TU ULL 463 | # elif defined(_LP64) 464 | # define CURL_TYPEOF_CURL_OFF_T long 465 | # define CURL_FORMAT_CURL_OFF_T "ld" 466 | # define CURL_FORMAT_CURL_OFF_TU "lu" 467 | # define CURL_FORMAT_OFF_T "%ld" 468 | # define CURL_SIZEOF_CURL_OFF_T 8 469 | # define CURL_SUFFIX_CURL_OFF_T L 470 | # define CURL_SUFFIX_CURL_OFF_TU UL 471 | # else 472 | # define CURL_TYPEOF_CURL_OFF_T long 473 | # define CURL_FORMAT_CURL_OFF_T "ld" 474 | # define CURL_FORMAT_CURL_OFF_TU "lu" 475 | # define CURL_FORMAT_OFF_T "%ld" 476 | # define CURL_SIZEOF_CURL_OFF_T 4 477 | # define CURL_SUFFIX_CURL_OFF_T L 478 | # define CURL_SUFFIX_CURL_OFF_TU UL 479 | # endif 480 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 481 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 482 | # define CURL_PULL_SYS_TYPES_H 1 483 | # define CURL_PULL_SYS_SOCKET_H 1 484 | # endif 485 | 486 | #elif defined(TPF) 487 | # define CURL_SIZEOF_LONG 8 488 | # define CURL_TYPEOF_CURL_OFF_T long 489 | # define CURL_FORMAT_CURL_OFF_T "ld" 490 | # define CURL_FORMAT_CURL_OFF_TU "lu" 491 | # define CURL_FORMAT_OFF_T "%ld" 492 | # define CURL_SIZEOF_CURL_OFF_T 8 493 | # define CURL_SUFFIX_CURL_OFF_T L 494 | # define CURL_SUFFIX_CURL_OFF_TU UL 495 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 496 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 497 | 498 | /* ===================================== */ 499 | /* KEEP MSVC THE PENULTIMATE ENTRY */ 500 | /* ===================================== */ 501 | 502 | #elif defined(_MSC_VER) 503 | # if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) 504 | # define CURL_SIZEOF_LONG 4 505 | # define CURL_TYPEOF_CURL_OFF_T __int64 506 | # define CURL_FORMAT_CURL_OFF_T "I64d" 507 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 508 | # define CURL_FORMAT_OFF_T "%I64d" 509 | # define CURL_SIZEOF_CURL_OFF_T 8 510 | # define CURL_SUFFIX_CURL_OFF_T i64 511 | # define CURL_SUFFIX_CURL_OFF_TU ui64 512 | # else 513 | # define CURL_SIZEOF_LONG 4 514 | # define CURL_TYPEOF_CURL_OFF_T long 515 | # define CURL_FORMAT_CURL_OFF_T "ld" 516 | # define CURL_FORMAT_CURL_OFF_TU "lu" 517 | # define CURL_FORMAT_OFF_T "%ld" 518 | # define CURL_SIZEOF_CURL_OFF_T 4 519 | # define CURL_SUFFIX_CURL_OFF_T L 520 | # define CURL_SUFFIX_CURL_OFF_TU UL 521 | # endif 522 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 523 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 524 | 525 | /* ===================================== */ 526 | /* KEEP GENERIC GCC THE LAST ENTRY */ 527 | /* ===================================== */ 528 | 529 | #elif defined(__GNUC__) 530 | # if !defined(__LP64__) && (defined(__ILP32__) || \ 531 | defined(__i386__) || defined(__ppc__) || defined(__arm__) || \ 532 | defined(__sparc__) || defined(__mips__) || defined(__sh__)) 533 | # define CURL_SIZEOF_LONG 4 534 | # define CURL_TYPEOF_CURL_OFF_T long long 535 | # define CURL_FORMAT_CURL_OFF_T "lld" 536 | # define CURL_FORMAT_CURL_OFF_TU "llu" 537 | # define CURL_FORMAT_OFF_T "%lld" 538 | # define CURL_SIZEOF_CURL_OFF_T 8 539 | # define CURL_SUFFIX_CURL_OFF_T LL 540 | # define CURL_SUFFIX_CURL_OFF_TU ULL 541 | # elif defined(__LP64__) || \ 542 | defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) 543 | # define CURL_SIZEOF_LONG 8 544 | # define CURL_TYPEOF_CURL_OFF_T long 545 | # define CURL_FORMAT_CURL_OFF_T "ld" 546 | # define CURL_FORMAT_CURL_OFF_TU "lu" 547 | # define CURL_FORMAT_OFF_T "%ld" 548 | # define CURL_SIZEOF_CURL_OFF_T 8 549 | # define CURL_SUFFIX_CURL_OFF_T L 550 | # define CURL_SUFFIX_CURL_OFF_TU UL 551 | # endif 552 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 553 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 554 | # define CURL_PULL_SYS_TYPES_H 1 555 | # define CURL_PULL_SYS_SOCKET_H 1 556 | 557 | #else 558 | # error "Unknown non-configure build target!" 559 | Error Compilation_aborted_Unknown_non_configure_build_target 560 | #endif 561 | 562 | /* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ 563 | /* sys/types.h is required here to properly make type definitions below. */ 564 | #ifdef CURL_PULL_SYS_TYPES_H 565 | # include 566 | #endif 567 | 568 | /* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ 569 | /* sys/socket.h is required here to properly make type definitions below. */ 570 | #ifdef CURL_PULL_SYS_SOCKET_H 571 | # include 572 | #endif 573 | 574 | /* Data type definition of curl_socklen_t. */ 575 | 576 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 577 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; 578 | #endif 579 | 580 | /* Data type definition of curl_off_t. */ 581 | 582 | #ifdef CURL_TYPEOF_CURL_OFF_T 583 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; 584 | #endif 585 | 586 | #endif /* __CURL_CURLBUILD_H */ 587 | -------------------------------------------------------------------------------- /curl_multi/libcurl/curlrules.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLRULES_H 2 | #define __CURL_CURLRULES_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* ================================================================ */ 26 | /* COMPILE TIME SANITY CHECKS */ 27 | /* ================================================================ */ 28 | 29 | /* 30 | * NOTE 1: 31 | * ------- 32 | * 33 | * All checks done in this file are intentionally placed in a public 34 | * header file which is pulled by curl/curl.h when an application is 35 | * being built using an already built libcurl library. Additionally 36 | * this file is also included and used when building the library. 37 | * 38 | * If compilation fails on this file it is certainly sure that the 39 | * problem is elsewhere. It could be a problem in the curlbuild.h 40 | * header file, or simply that you are using different compilation 41 | * settings than those used to build the library. 42 | * 43 | * Nothing in this file is intended to be modified or adjusted by the 44 | * curl library user nor by the curl library builder. 45 | * 46 | * Do not deactivate any check, these are done to make sure that the 47 | * library is properly built and used. 48 | * 49 | * You can find further help on the libcurl development mailing list: 50 | * https://cool.haxx.se/mailman/listinfo/curl-library/ 51 | * 52 | * NOTE 2 53 | * ------ 54 | * 55 | * Some of the following compile time checks are based on the fact 56 | * that the dimension of a constant array can not be a negative one. 57 | * In this way if the compile time verification fails, the compilation 58 | * will fail issuing an error. The error description wording is compiler 59 | * dependent but it will be quite similar to one of the following: 60 | * 61 | * "negative subscript or subscript is too large" 62 | * "array must have at least one element" 63 | * "-1 is an illegal array size" 64 | * "size of array is negative" 65 | * 66 | * If you are building an application which tries to use an already 67 | * built libcurl library and you are getting this kind of errors on 68 | * this file, it is a clear indication that there is a mismatch between 69 | * how the library was built and how you are trying to use it for your 70 | * application. Your already compiled or binary library provider is the 71 | * only one who can give you the details you need to properly use it. 72 | */ 73 | 74 | /* 75 | * Verify that some macros are actually defined. 76 | */ 77 | 78 | #ifndef CURL_SIZEOF_LONG 79 | # error "CURL_SIZEOF_LONG definition is missing!" 80 | Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing 81 | #endif 82 | 83 | #ifndef CURL_TYPEOF_CURL_SOCKLEN_T 84 | # error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!" 85 | Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing 86 | #endif 87 | 88 | #ifndef CURL_SIZEOF_CURL_SOCKLEN_T 89 | # error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!" 90 | Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing 91 | #endif 92 | 93 | #ifndef CURL_TYPEOF_CURL_OFF_T 94 | # error "CURL_TYPEOF_CURL_OFF_T definition is missing!" 95 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing 96 | #endif 97 | 98 | #ifndef CURL_FORMAT_CURL_OFF_T 99 | # error "CURL_FORMAT_CURL_OFF_T definition is missing!" 100 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing 101 | #endif 102 | 103 | #ifndef CURL_FORMAT_CURL_OFF_TU 104 | # error "CURL_FORMAT_CURL_OFF_TU definition is missing!" 105 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing 106 | #endif 107 | 108 | #ifndef CURL_FORMAT_OFF_T 109 | # error "CURL_FORMAT_OFF_T definition is missing!" 110 | Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing 111 | #endif 112 | 113 | #ifndef CURL_SIZEOF_CURL_OFF_T 114 | # error "CURL_SIZEOF_CURL_OFF_T definition is missing!" 115 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing 116 | #endif 117 | 118 | #ifndef CURL_SUFFIX_CURL_OFF_T 119 | # error "CURL_SUFFIX_CURL_OFF_T definition is missing!" 120 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing 121 | #endif 122 | 123 | #ifndef CURL_SUFFIX_CURL_OFF_TU 124 | # error "CURL_SUFFIX_CURL_OFF_TU definition is missing!" 125 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing 126 | #endif 127 | 128 | /* 129 | * Macros private to this header file. 130 | */ 131 | 132 | #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1 133 | 134 | #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 135 | 136 | /* 137 | * Verify that the size previously defined and expected for long 138 | * is the same as the one reported by sizeof() at compile time. 139 | */ 140 | 141 | typedef char 142 | __curl_rule_01__ 143 | [CurlchkszEQ(long, CURL_SIZEOF_LONG)]; 144 | 145 | /* 146 | * Verify that the size previously defined and expected for 147 | * curl_off_t is actually the the same as the one reported 148 | * by sizeof() at compile time. 149 | */ 150 | 151 | typedef char 152 | __curl_rule_02__ 153 | [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)]; 154 | 155 | /* 156 | * Verify at compile time that the size of curl_off_t as reported 157 | * by sizeof() is greater or equal than the one reported for long 158 | * for the current compilation. 159 | */ 160 | 161 | typedef char 162 | __curl_rule_03__ 163 | [CurlchkszGE(curl_off_t, long)]; 164 | 165 | /* 166 | * Verify that the size previously defined and expected for 167 | * curl_socklen_t is actually the the same as the one reported 168 | * by sizeof() at compile time. 169 | */ 170 | 171 | typedef char 172 | __curl_rule_04__ 173 | [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)]; 174 | 175 | /* 176 | * Verify at compile time that the size of curl_socklen_t as reported 177 | * by sizeof() is greater or equal than the one reported for int for 178 | * the current compilation. 179 | */ 180 | 181 | typedef char 182 | __curl_rule_05__ 183 | [CurlchkszGE(curl_socklen_t, int)]; 184 | 185 | /* ================================================================ */ 186 | /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ 187 | /* ================================================================ */ 188 | 189 | /* 190 | * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow 191 | * these to be visible and exported by the external libcurl interface API, 192 | * while also making them visible to the library internals, simply including 193 | * curl_setup.h, without actually needing to include curl.h internally. 194 | * If some day this section would grow big enough, all this should be moved 195 | * to its own header file. 196 | */ 197 | 198 | /* 199 | * Figure out if we can use the ## preprocessor operator, which is supported 200 | * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__ 201 | * or __cplusplus so we need to carefully check for them too. 202 | */ 203 | 204 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ 205 | defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ 206 | defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ 207 | defined(__ILEC400__) 208 | /* This compiler is believed to have an ISO compatible preprocessor */ 209 | #define CURL_ISOCPP 210 | #else 211 | /* This compiler is believed NOT to have an ISO compatible preprocessor */ 212 | #undef CURL_ISOCPP 213 | #endif 214 | 215 | /* 216 | * Macros for minimum-width signed and unsigned curl_off_t integer constants. 217 | */ 218 | 219 | #if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551) 220 | # define __CURL_OFF_T_C_HLPR2(x) x 221 | # define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x) 222 | # define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ 223 | __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T) 224 | # define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ 225 | __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU) 226 | #else 227 | # ifdef CURL_ISOCPP 228 | # define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix 229 | # else 230 | # define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix 231 | # endif 232 | # define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix) 233 | # define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T) 234 | # define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU) 235 | #endif 236 | 237 | /* 238 | * Get rid of macros private to this header file. 239 | */ 240 | 241 | #undef CurlchkszEQ 242 | #undef CurlchkszGE 243 | 244 | /* 245 | * Get rid of macros not intended to exist beyond this point. 246 | */ 247 | 248 | #undef CURL_PULL_WS2TCPIP_H 249 | #undef CURL_PULL_SYS_TYPES_H 250 | #undef CURL_PULL_SYS_SOCKET_H 251 | #undef CURL_PULL_SYS_POLL_H 252 | #undef CURL_PULL_STDINT_H 253 | #undef CURL_PULL_INTTYPES_H 254 | 255 | #undef CURL_TYPEOF_CURL_SOCKLEN_T 256 | #undef CURL_TYPEOF_CURL_OFF_T 257 | 258 | #ifdef CURL_NO_OLDIES 259 | #undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */ 260 | #endif 261 | 262 | #endif /* __CURL_CURLRULES_H */ 263 | -------------------------------------------------------------------------------- /curl_multi/libcurl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLVER_H 2 | #define __CURL_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* This header file contains nothing but libcurl version info, generated by 26 | a script at release-time. This was made its own header file in 7.11.2 */ 27 | 28 | /* This is the global package copyright */ 29 | #define LIBCURL_COPYRIGHT "1996 - 2016 Daniel Stenberg, ." 30 | 31 | /* This is the version number of the libcurl package from which this header 32 | file origins: */ 33 | #define LIBCURL_VERSION "7.51.0" 34 | 35 | /* The numeric version number is also available "in parts" by using these 36 | defines: */ 37 | #define LIBCURL_VERSION_MAJOR 7 38 | #define LIBCURL_VERSION_MINOR 51 39 | #define LIBCURL_VERSION_PATCH 0 40 | 41 | /* This is the numeric version of the libcurl version number, meant for easier 42 | parsing and comparions by programs. The LIBCURL_VERSION_NUM define will 43 | always follow this syntax: 44 | 45 | 0xXXYYZZ 46 | 47 | Where XX, YY and ZZ are the main version, release and patch numbers in 48 | hexadecimal (using 8 bits each). All three numbers are always represented 49 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 50 | appears as "0x090b07". 51 | 52 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 53 | and it is always a greater number in a more recent release. It makes 54 | comparisons with greater than and less than work. 55 | 56 | Note: This define is the full hex number and _does not_ use the 57 | CURL_VERSION_BITS() macro since curl's own configure script greps for it 58 | and needs it to contain the full number. 59 | */ 60 | #define LIBCURL_VERSION_NUM 0x073300 61 | 62 | /* 63 | * This is the date and time when the full source package was created. The 64 | * timestamp is not stored in git, as the timestamp is properly set in the 65 | * tarballs by the maketgz script. 66 | * 67 | * The format of the date should follow this template: 68 | * 69 | * "Mon Feb 12 11:35:33 UTC 2007" 70 | */ 71 | #define LIBCURL_TIMESTAMP "Wed Nov 2 06:54:46 UTC 2016" 72 | 73 | #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) 74 | #define CURL_AT_LEAST_VERSION(x,y,z) \ 75 | (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) 76 | 77 | #endif /* __CURL_CURLVER_H */ 78 | -------------------------------------------------------------------------------- /curl_multi/libcurl/easy.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_EASY_H 2 | #define __CURL_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | CURL_EXTERN CURL *curl_easy_init(void); 29 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 30 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 31 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 32 | 33 | /* 34 | * NAME curl_easy_getinfo() 35 | * 36 | * DESCRIPTION 37 | * 38 | * Request internal information from the curl session with this function. The 39 | * third argument MUST be a pointer to a long, a pointer to a char * or a 40 | * pointer to a double (as the documentation describes elsewhere). The data 41 | * pointed to will be filled in accordingly and can be relied upon only if the 42 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 43 | * performed transfer, all results from this function are undefined until the 44 | * transfer is completed. 45 | */ 46 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 47 | 48 | 49 | /* 50 | * NAME curl_easy_duphandle() 51 | * 52 | * DESCRIPTION 53 | * 54 | * Creates a new curl session handle with the same options set for the handle 55 | * passed in. Duplicating a handle could only be a matter of cloning data and 56 | * options, internal state info and things like persistent connections cannot 57 | * be transferred. It is useful in multithreaded applications when you can run 58 | * curl_easy_duphandle() for each new thread to avoid a series of identical 59 | * curl_easy_setopt() invokes in every thread. 60 | */ 61 | CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); 62 | 63 | /* 64 | * NAME curl_easy_reset() 65 | * 66 | * DESCRIPTION 67 | * 68 | * Re-initializes a CURL handle to the default values. This puts back the 69 | * handle to the same state as it was in when it was just created. 70 | * 71 | * It does keep: live connections, the Session ID cache, the DNS cache and the 72 | * cookies. 73 | */ 74 | CURL_EXTERN void curl_easy_reset(CURL *curl); 75 | 76 | /* 77 | * NAME curl_easy_recv() 78 | * 79 | * DESCRIPTION 80 | * 81 | * Receives data from the connected socket. Use after successful 82 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 83 | */ 84 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 85 | size_t *n); 86 | 87 | /* 88 | * NAME curl_easy_send() 89 | * 90 | * DESCRIPTION 91 | * 92 | * Sends data over the connected socket. Use after successful 93 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 94 | */ 95 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, 96 | size_t buflen, size_t *n); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/libcurl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/libcurl.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/libcurld.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/libcurld.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/libeay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/libeay32.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/libeay32d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/libeay32d.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/ssleay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/ssleay32.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/ssleay32d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/ssleay32d.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/zlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/zlib.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/lib/zlibd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libcurl/lib/zlibd.lib -------------------------------------------------------------------------------- /curl_multi/libcurl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MPRINTF_H 2 | #define __CURL_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | #include /* needed for FILE */ 27 | #include "curl.h" /* for CURL_EXTERN */ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | CURL_EXTERN int curl_mprintf(const char *format, ...); 34 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 35 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 36 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 37 | const char *format, ...); 38 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 39 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 40 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 42 | const char *format, va_list args); 43 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 44 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* __CURL_MPRINTF_H */ 51 | -------------------------------------------------------------------------------- /curl_multi/libcurl/multi.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MULTI_H 2 | #define __CURL_MULTI_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | /* 25 | This is an "external" header file. Don't give away any internals here! 26 | 27 | GOALS 28 | 29 | o Enable a "pull" interface. The application that uses libcurl decides where 30 | and when to ask libcurl to get/send data. 31 | 32 | o Enable multiple simultaneous transfers in the same thread without making it 33 | complicated for the application. 34 | 35 | o Enable the application to select() on its own file descriptors and curl's 36 | file descriptors simultaneous easily. 37 | 38 | */ 39 | 40 | /* 41 | * This header file should not really need to include "curl.h" since curl.h 42 | * itself includes this file and we expect user applications to do #include 43 | * without the need for especially including multi.h. 44 | * 45 | * For some reason we added this include here at one point, and rather than to 46 | * break existing (wrongly written) libcurl applications, we leave it as-is 47 | * but with this warning attached. 48 | */ 49 | #include "curl.h" 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | #if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER) 56 | typedef struct Curl_multi CURLM; 57 | #else 58 | typedef void CURLM; 59 | #endif 60 | 61 | typedef enum { 62 | CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or 63 | curl_multi_socket*() soon */ 64 | CURLM_OK, 65 | CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ 66 | CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ 67 | CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ 68 | CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ 69 | CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ 70 | CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ 71 | CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was 72 | attempted to get added - again */ 73 | CURLM_LAST 74 | } CURLMcode; 75 | 76 | /* just to make code nicer when using curl_multi_socket() you can now check 77 | for CURLM_CALL_MULTI_SOCKET too in the same style it works for 78 | curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ 79 | #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM 80 | 81 | /* bitmask bits for CURLMOPT_PIPELINING */ 82 | #define CURLPIPE_NOTHING 0L 83 | #define CURLPIPE_HTTP1 1L 84 | #define CURLPIPE_MULTIPLEX 2L 85 | 86 | typedef enum { 87 | CURLMSG_NONE, /* first, not used */ 88 | CURLMSG_DONE, /* This easy handle has completed. 'result' contains 89 | the CURLcode of the transfer */ 90 | CURLMSG_LAST /* last, not used */ 91 | } CURLMSG; 92 | 93 | struct CURLMsg { 94 | CURLMSG msg; /* what this message means */ 95 | CURL *easy_handle; /* the handle it concerns */ 96 | union { 97 | void *whatever; /* message-specific data */ 98 | CURLcode result; /* return code for transfer */ 99 | } data; 100 | }; 101 | typedef struct CURLMsg CURLMsg; 102 | 103 | /* Based on poll(2) structure and values. 104 | * We don't use pollfd and POLL* constants explicitly 105 | * to cover platforms without poll(). */ 106 | #define CURL_WAIT_POLLIN 0x0001 107 | #define CURL_WAIT_POLLPRI 0x0002 108 | #define CURL_WAIT_POLLOUT 0x0004 109 | 110 | struct curl_waitfd { 111 | curl_socket_t fd; 112 | short events; 113 | short revents; /* not supported yet */ 114 | }; 115 | 116 | /* 117 | * Name: curl_multi_init() 118 | * 119 | * Desc: inititalize multi-style curl usage 120 | * 121 | * Returns: a new CURLM handle to use in all 'curl_multi' functions. 122 | */ 123 | CURL_EXTERN CURLM *curl_multi_init(void); 124 | 125 | /* 126 | * Name: curl_multi_add_handle() 127 | * 128 | * Desc: add a standard curl handle to the multi stack 129 | * 130 | * Returns: CURLMcode type, general multi error code. 131 | */ 132 | CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, 133 | CURL *curl_handle); 134 | 135 | /* 136 | * Name: curl_multi_remove_handle() 137 | * 138 | * Desc: removes a curl handle from the multi stack again 139 | * 140 | * Returns: CURLMcode type, general multi error code. 141 | */ 142 | CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, 143 | CURL *curl_handle); 144 | 145 | /* 146 | * Name: curl_multi_fdset() 147 | * 148 | * Desc: Ask curl for its fd_set sets. The app can use these to select() or 149 | * poll() on. We want curl_multi_perform() called as soon as one of 150 | * them are ready. 151 | * 152 | * Returns: CURLMcode type, general multi error code. 153 | */ 154 | CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, 155 | fd_set *read_fd_set, 156 | fd_set *write_fd_set, 157 | fd_set *exc_fd_set, 158 | int *max_fd); 159 | 160 | /* 161 | * Name: curl_multi_wait() 162 | * 163 | * Desc: Poll on all fds within a CURLM set as well as any 164 | * additional fds passed to the function. 165 | * 166 | * Returns: CURLMcode type, general multi error code. 167 | */ 168 | CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, 169 | struct curl_waitfd extra_fds[], 170 | unsigned int extra_nfds, 171 | int timeout_ms, 172 | int *ret); 173 | 174 | /* 175 | * Name: curl_multi_perform() 176 | * 177 | * Desc: When the app thinks there's data available for curl it calls this 178 | * function to read/write whatever there is right now. This returns 179 | * as soon as the reads and writes are done. This function does not 180 | * require that there actually is data available for reading or that 181 | * data can be written, it can be called just in case. It returns 182 | * the number of handles that still transfer data in the second 183 | * argument's integer-pointer. 184 | * 185 | * Returns: CURLMcode type, general multi error code. *NOTE* that this only 186 | * returns errors etc regarding the whole multi stack. There might 187 | * still have occurred problems on invidual transfers even when this 188 | * returns OK. 189 | */ 190 | CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, 191 | int *running_handles); 192 | 193 | /* 194 | * Name: curl_multi_cleanup() 195 | * 196 | * Desc: Cleans up and removes a whole multi stack. It does not free or 197 | * touch any individual easy handles in any way. We need to define 198 | * in what state those handles will be if this function is called 199 | * in the middle of a transfer. 200 | * 201 | * Returns: CURLMcode type, general multi error code. 202 | */ 203 | CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); 204 | 205 | /* 206 | * Name: curl_multi_info_read() 207 | * 208 | * Desc: Ask the multi handle if there's any messages/informationals from 209 | * the individual transfers. Messages include informationals such as 210 | * error code from the transfer or just the fact that a transfer is 211 | * completed. More details on these should be written down as well. 212 | * 213 | * Repeated calls to this function will return a new struct each 214 | * time, until a special "end of msgs" struct is returned as a signal 215 | * that there is no more to get at this point. 216 | * 217 | * The data the returned pointer points to will not survive calling 218 | * curl_multi_cleanup(). 219 | * 220 | * The 'CURLMsg' struct is meant to be very simple and only contain 221 | * very basic informations. If more involved information is wanted, 222 | * we will provide the particular "transfer handle" in that struct 223 | * and that should/could/would be used in subsequent 224 | * curl_easy_getinfo() calls (or similar). The point being that we 225 | * must never expose complex structs to applications, as then we'll 226 | * undoubtably get backwards compatibility problems in the future. 227 | * 228 | * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out 229 | * of structs. It also writes the number of messages left in the 230 | * queue (after this read) in the integer the second argument points 231 | * to. 232 | */ 233 | CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, 234 | int *msgs_in_queue); 235 | 236 | /* 237 | * Name: curl_multi_strerror() 238 | * 239 | * Desc: The curl_multi_strerror function may be used to turn a CURLMcode 240 | * value into the equivalent human readable error string. This is 241 | * useful for printing meaningful error messages. 242 | * 243 | * Returns: A pointer to a zero-terminated error message. 244 | */ 245 | CURL_EXTERN const char *curl_multi_strerror(CURLMcode); 246 | 247 | /* 248 | * Name: curl_multi_socket() and 249 | * curl_multi_socket_all() 250 | * 251 | * Desc: An alternative version of curl_multi_perform() that allows the 252 | * application to pass in one of the file descriptors that have been 253 | * detected to have "action" on them and let libcurl perform. 254 | * See man page for details. 255 | */ 256 | #define CURL_POLL_NONE 0 257 | #define CURL_POLL_IN 1 258 | #define CURL_POLL_OUT 2 259 | #define CURL_POLL_INOUT 3 260 | #define CURL_POLL_REMOVE 4 261 | 262 | #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD 263 | 264 | #define CURL_CSELECT_IN 0x01 265 | #define CURL_CSELECT_OUT 0x02 266 | #define CURL_CSELECT_ERR 0x04 267 | 268 | typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ 269 | curl_socket_t s, /* socket */ 270 | int what, /* see above */ 271 | void *userp, /* private callback 272 | pointer */ 273 | void *socketp); /* private socket 274 | pointer */ 275 | /* 276 | * Name: curl_multi_timer_callback 277 | * 278 | * Desc: Called by libcurl whenever the library detects a change in the 279 | * maximum number of milliseconds the app is allowed to wait before 280 | * curl_multi_socket() or curl_multi_perform() must be called 281 | * (to allow libcurl's timed events to take place). 282 | * 283 | * Returns: The callback should return zero. 284 | */ 285 | typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ 286 | long timeout_ms, /* see above */ 287 | void *userp); /* private callback 288 | pointer */ 289 | 290 | CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, 291 | int *running_handles); 292 | 293 | CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, 294 | curl_socket_t s, 295 | int ev_bitmask, 296 | int *running_handles); 297 | 298 | CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, 299 | int *running_handles); 300 | 301 | #ifndef CURL_ALLOW_OLD_MULTI_SOCKET 302 | /* This macro below was added in 7.16.3 to push users who recompile to use 303 | the new curl_multi_socket_action() instead of the old curl_multi_socket() 304 | */ 305 | #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) 306 | #endif 307 | 308 | /* 309 | * Name: curl_multi_timeout() 310 | * 311 | * Desc: Returns the maximum number of milliseconds the app is allowed to 312 | * wait before curl_multi_socket() or curl_multi_perform() must be 313 | * called (to allow libcurl's timed events to take place). 314 | * 315 | * Returns: CURLM error code. 316 | */ 317 | CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, 318 | long *milliseconds); 319 | 320 | #undef CINIT /* re-using the same name as in curl.h */ 321 | 322 | #ifdef CURL_ISOCPP 323 | #define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num 324 | #else 325 | /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ 326 | #define LONG CURLOPTTYPE_LONG 327 | #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT 328 | #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT 329 | #define OFF_T CURLOPTTYPE_OFF_T 330 | #define CINIT(name,type,number) CURLMOPT_/**/name = type + number 331 | #endif 332 | 333 | typedef enum { 334 | /* This is the socket callback function pointer */ 335 | CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), 336 | 337 | /* This is the argument passed to the socket callback */ 338 | CINIT(SOCKETDATA, OBJECTPOINT, 2), 339 | 340 | /* set to 1 to enable pipelining for this multi handle */ 341 | CINIT(PIPELINING, LONG, 3), 342 | 343 | /* This is the timer callback function pointer */ 344 | CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), 345 | 346 | /* This is the argument passed to the timer callback */ 347 | CINIT(TIMERDATA, OBJECTPOINT, 5), 348 | 349 | /* maximum number of entries in the connection cache */ 350 | CINIT(MAXCONNECTS, LONG, 6), 351 | 352 | /* maximum number of (pipelining) connections to one host */ 353 | CINIT(MAX_HOST_CONNECTIONS, LONG, 7), 354 | 355 | /* maximum number of requests in a pipeline */ 356 | CINIT(MAX_PIPELINE_LENGTH, LONG, 8), 357 | 358 | /* a connection with a content-length longer than this 359 | will not be considered for pipelining */ 360 | CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9), 361 | 362 | /* a connection with a chunk length longer than this 363 | will not be considered for pipelining */ 364 | CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10), 365 | 366 | /* a list of site names(+port) that are blacklisted from 367 | pipelining */ 368 | CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11), 369 | 370 | /* a list of server types that are blacklisted from 371 | pipelining */ 372 | CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12), 373 | 374 | /* maximum number of open connections in total */ 375 | CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13), 376 | 377 | /* This is the server push callback function pointer */ 378 | CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14), 379 | 380 | /* This is the argument passed to the server push callback */ 381 | CINIT(PUSHDATA, OBJECTPOINT, 15), 382 | 383 | CURLMOPT_LASTENTRY /* the last unused */ 384 | } CURLMoption; 385 | 386 | 387 | /* 388 | * Name: curl_multi_setopt() 389 | * 390 | * Desc: Sets options for the multi handle. 391 | * 392 | * Returns: CURLM error code. 393 | */ 394 | CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, 395 | CURLMoption option, ...); 396 | 397 | 398 | /* 399 | * Name: curl_multi_assign() 400 | * 401 | * Desc: This function sets an association in the multi handle between the 402 | * given socket and a private pointer of the application. This is 403 | * (only) useful for curl_multi_socket uses. 404 | * 405 | * Returns: CURLM error code. 406 | */ 407 | CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, 408 | curl_socket_t sockfd, void *sockp); 409 | 410 | 411 | /* 412 | * Name: curl_push_callback 413 | * 414 | * Desc: This callback gets called when a new stream is being pushed by the 415 | * server. It approves or denies the new stream. 416 | * 417 | * Returns: CURL_PUSH_OK or CURL_PUSH_DENY. 418 | */ 419 | #define CURL_PUSH_OK 0 420 | #define CURL_PUSH_DENY 1 421 | 422 | struct curl_pushheaders; /* forward declaration only */ 423 | 424 | CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h, 425 | size_t num); 426 | CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h, 427 | const char *name); 428 | 429 | typedef int (*curl_push_callback)(CURL *parent, 430 | CURL *easy, 431 | size_t num_headers, 432 | struct curl_pushheaders *headers, 433 | void *userp); 434 | 435 | #ifdef __cplusplus 436 | } /* end of extern "C" */ 437 | #endif 438 | 439 | #endif 440 | -------------------------------------------------------------------------------- /curl_multi/libcurl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDC_HEADERS_H 2 | #define __STDC_HEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread (void *, size_t, size_t, FILE *); 28 | size_t fwrite (const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* __STDC_HEADERS_H */ 34 | -------------------------------------------------------------------------------- /curl_multi/libcurl/zlib/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 15 | * this permanently in zconf.h using "./configure --zprefix". 16 | */ 17 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 18 | # define Z_PREFIX_SET 19 | 20 | /* all linked symbols */ 21 | # define _dist_code z__dist_code 22 | # define _length_code z__length_code 23 | # define _tr_align z__tr_align 24 | # define _tr_flush_bits z__tr_flush_bits 25 | # define _tr_flush_block z__tr_flush_block 26 | # define _tr_init z__tr_init 27 | # define _tr_stored_block z__tr_stored_block 28 | # define _tr_tally z__tr_tally 29 | # define adler32 z_adler32 30 | # define adler32_combine z_adler32_combine 31 | # define adler32_combine64 z_adler32_combine64 32 | # ifndef Z_SOLO 33 | # define compress z_compress 34 | # define compress2 z_compress2 35 | # define compressBound z_compressBound 36 | # endif 37 | # define crc32 z_crc32 38 | # define crc32_combine z_crc32_combine 39 | # define crc32_combine64 z_crc32_combine64 40 | # define deflate z_deflate 41 | # define deflateBound z_deflateBound 42 | # define deflateCopy z_deflateCopy 43 | # define deflateEnd z_deflateEnd 44 | # define deflateInit2_ z_deflateInit2_ 45 | # define deflateInit_ z_deflateInit_ 46 | # define deflateParams z_deflateParams 47 | # define deflatePending z_deflatePending 48 | # define deflatePrime z_deflatePrime 49 | # define deflateReset z_deflateReset 50 | # define deflateResetKeep z_deflateResetKeep 51 | # define deflateSetDictionary z_deflateSetDictionary 52 | # define deflateSetHeader z_deflateSetHeader 53 | # define deflateTune z_deflateTune 54 | # define deflate_copyright z_deflate_copyright 55 | # define get_crc_table z_get_crc_table 56 | # ifndef Z_SOLO 57 | # define gz_error z_gz_error 58 | # define gz_intmax z_gz_intmax 59 | # define gz_strwinerror z_gz_strwinerror 60 | # define gzbuffer z_gzbuffer 61 | # define gzclearerr z_gzclearerr 62 | # define gzclose z_gzclose 63 | # define gzclose_r z_gzclose_r 64 | # define gzclose_w z_gzclose_w 65 | # define gzdirect z_gzdirect 66 | # define gzdopen z_gzdopen 67 | # define gzeof z_gzeof 68 | # define gzerror z_gzerror 69 | # define gzflush z_gzflush 70 | # define gzgetc z_gzgetc 71 | # define gzgetc_ z_gzgetc_ 72 | # define gzgets z_gzgets 73 | # define gzoffset z_gzoffset 74 | # define gzoffset64 z_gzoffset64 75 | # define gzopen z_gzopen 76 | # define gzopen64 z_gzopen64 77 | # ifdef _WIN32 78 | # define gzopen_w z_gzopen_w 79 | # endif 80 | # define gzprintf z_gzprintf 81 | # define gzvprintf z_gzvprintf 82 | # define gzputc z_gzputc 83 | # define gzputs z_gzputs 84 | # define gzread z_gzread 85 | # define gzrewind z_gzrewind 86 | # define gzseek z_gzseek 87 | # define gzseek64 z_gzseek64 88 | # define gzsetparams z_gzsetparams 89 | # define gztell z_gztell 90 | # define gztell64 z_gztell64 91 | # define gzungetc z_gzungetc 92 | # define gzwrite z_gzwrite 93 | # endif 94 | # define inflate z_inflate 95 | # define inflateBack z_inflateBack 96 | # define inflateBackEnd z_inflateBackEnd 97 | # define inflateBackInit_ z_inflateBackInit_ 98 | # define inflateCopy z_inflateCopy 99 | # define inflateEnd z_inflateEnd 100 | # define inflateGetHeader z_inflateGetHeader 101 | # define inflateInit2_ z_inflateInit2_ 102 | # define inflateInit_ z_inflateInit_ 103 | # define inflateMark z_inflateMark 104 | # define inflatePrime z_inflatePrime 105 | # define inflateReset z_inflateReset 106 | # define inflateReset2 z_inflateReset2 107 | # define inflateSetDictionary z_inflateSetDictionary 108 | # define inflateGetDictionary z_inflateGetDictionary 109 | # define inflateSync z_inflateSync 110 | # define inflateSyncPoint z_inflateSyncPoint 111 | # define inflateUndermine z_inflateUndermine 112 | # define inflateResetKeep z_inflateResetKeep 113 | # define inflate_copyright z_inflate_copyright 114 | # define inflate_fast z_inflate_fast 115 | # define inflate_table z_inflate_table 116 | # ifndef Z_SOLO 117 | # define uncompress z_uncompress 118 | # endif 119 | # define zError z_zError 120 | # ifndef Z_SOLO 121 | # define zcalloc z_zcalloc 122 | # define zcfree z_zcfree 123 | # endif 124 | # define zlibCompileFlags z_zlibCompileFlags 125 | # define zlibVersion z_zlibVersion 126 | 127 | /* all zlib typedefs in zlib.h and zconf.h */ 128 | # define Byte z_Byte 129 | # define Bytef z_Bytef 130 | # define alloc_func z_alloc_func 131 | # define charf z_charf 132 | # define free_func z_free_func 133 | # ifndef Z_SOLO 134 | # define gzFile z_gzFile 135 | # endif 136 | # define gz_header z_gz_header 137 | # define gz_headerp z_gz_headerp 138 | # define in_func z_in_func 139 | # define intf z_intf 140 | # define out_func z_out_func 141 | # define uInt z_uInt 142 | # define uIntf z_uIntf 143 | # define uLong z_uLong 144 | # define uLongf z_uLongf 145 | # define voidp z_voidp 146 | # define voidpc z_voidpc 147 | # define voidpf z_voidpf 148 | 149 | /* all zlib structs in zlib.h and zconf.h */ 150 | # define gz_header_s z_gz_header_s 151 | # define internal_state z_internal_state 152 | 153 | #endif 154 | 155 | #if defined(__MSDOS__) && !defined(MSDOS) 156 | # define MSDOS 157 | #endif 158 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 159 | # define OS2 160 | #endif 161 | #if defined(_WINDOWS) && !defined(WINDOWS) 162 | # define WINDOWS 163 | #endif 164 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 165 | # ifndef WIN32 166 | # define WIN32 167 | # endif 168 | #endif 169 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 170 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 171 | # ifndef SYS16BIT 172 | # define SYS16BIT 173 | # endif 174 | # endif 175 | #endif 176 | 177 | /* 178 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 179 | * than 64k bytes at a time (needed on systems with 16-bit int). 180 | */ 181 | #ifdef SYS16BIT 182 | # define MAXSEG_64K 183 | #endif 184 | #ifdef MSDOS 185 | # define UNALIGNED_OK 186 | #endif 187 | 188 | #ifdef __STDC_VERSION__ 189 | # ifndef STDC 190 | # define STDC 191 | # endif 192 | # if __STDC_VERSION__ >= 199901L 193 | # ifndef STDC99 194 | # define STDC99 195 | # endif 196 | # endif 197 | #endif 198 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 199 | # define STDC 200 | #endif 201 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 202 | # define STDC 203 | #endif 204 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 205 | # define STDC 206 | #endif 207 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 208 | # define STDC 209 | #endif 210 | 211 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 212 | # define STDC 213 | #endif 214 | 215 | #ifndef STDC 216 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 217 | # define const /* note: need a more gentle solution here */ 218 | # endif 219 | #endif 220 | 221 | #if defined(ZLIB_CONST) && !defined(z_const) 222 | # define z_const const 223 | #else 224 | # define z_const 225 | #endif 226 | 227 | /* Some Mac compilers merge all .h files incorrectly: */ 228 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 229 | # define NO_DUMMY_DECL 230 | #endif 231 | 232 | /* Maximum value for memLevel in deflateInit2 */ 233 | #ifndef MAX_MEM_LEVEL 234 | # ifdef MAXSEG_64K 235 | # define MAX_MEM_LEVEL 8 236 | # else 237 | # define MAX_MEM_LEVEL 9 238 | # endif 239 | #endif 240 | 241 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 242 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 243 | * created by gzip. (Files created by minigzip can still be extracted by 244 | * gzip.) 245 | */ 246 | #ifndef MAX_WBITS 247 | # define MAX_WBITS 15 /* 32K LZ77 window */ 248 | #endif 249 | 250 | /* The memory requirements for deflate are (in bytes): 251 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 252 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 253 | plus a few kilobytes for small objects. For example, if you want to reduce 254 | the default memory requirements from 256K to 128K, compile with 255 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 256 | Of course this will generally degrade compression (there's no free lunch). 257 | 258 | The memory requirements for inflate are (in bytes) 1 << windowBits 259 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 260 | for small objects. 261 | */ 262 | 263 | /* Type declarations */ 264 | 265 | #ifndef OF /* function prototypes */ 266 | # ifdef STDC 267 | # define OF(args) args 268 | # else 269 | # define OF(args) () 270 | # endif 271 | #endif 272 | 273 | #ifndef Z_ARG /* function prototypes for stdarg */ 274 | # if defined(STDC) || defined(Z_HAVE_STDARG_H) 275 | # define Z_ARG(args) args 276 | # else 277 | # define Z_ARG(args) () 278 | # endif 279 | #endif 280 | 281 | /* The following definitions for FAR are needed only for MSDOS mixed 282 | * model programming (small or medium model with some far allocations). 283 | * This was tested only with MSC; for other MSDOS compilers you may have 284 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 285 | * just define FAR to be empty. 286 | */ 287 | #ifdef SYS16BIT 288 | # if defined(M_I86SM) || defined(M_I86MM) 289 | /* MSC small or medium model */ 290 | # define SMALL_MEDIUM 291 | # ifdef _MSC_VER 292 | # define FAR _far 293 | # else 294 | # define FAR far 295 | # endif 296 | # endif 297 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 298 | /* Turbo C small or medium model */ 299 | # define SMALL_MEDIUM 300 | # ifdef __BORLANDC__ 301 | # define FAR _far 302 | # else 303 | # define FAR far 304 | # endif 305 | # endif 306 | #endif 307 | 308 | #if defined(WINDOWS) || defined(WIN32) 309 | /* If building or using zlib as a DLL, define ZLIB_DLL. 310 | * This is not mandatory, but it offers a little performance increase. 311 | */ 312 | # ifdef ZLIB_DLL 313 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 314 | # ifdef ZLIB_INTERNAL 315 | # define ZEXTERN extern __declspec(dllexport) 316 | # else 317 | # define ZEXTERN extern __declspec(dllimport) 318 | # endif 319 | # endif 320 | # endif /* ZLIB_DLL */ 321 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 322 | * define ZLIB_WINAPI. 323 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 324 | */ 325 | # ifdef ZLIB_WINAPI 326 | # ifdef FAR 327 | # undef FAR 328 | # endif 329 | # include 330 | /* No need for _export, use ZLIB.DEF instead. */ 331 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 332 | # define ZEXPORT WINAPI 333 | # ifdef WIN32 334 | # define ZEXPORTVA WINAPIV 335 | # else 336 | # define ZEXPORTVA FAR CDECL 337 | # endif 338 | # endif 339 | #endif 340 | 341 | #if defined (__BEOS__) 342 | # ifdef ZLIB_DLL 343 | # ifdef ZLIB_INTERNAL 344 | # define ZEXPORT __declspec(dllexport) 345 | # define ZEXPORTVA __declspec(dllexport) 346 | # else 347 | # define ZEXPORT __declspec(dllimport) 348 | # define ZEXPORTVA __declspec(dllimport) 349 | # endif 350 | # endif 351 | #endif 352 | 353 | #ifndef ZEXTERN 354 | # define ZEXTERN extern 355 | #endif 356 | #ifndef ZEXPORT 357 | # define ZEXPORT 358 | #endif 359 | #ifndef ZEXPORTVA 360 | # define ZEXPORTVA 361 | #endif 362 | 363 | #ifndef FAR 364 | # define FAR 365 | #endif 366 | 367 | #if !defined(__MACTYPES__) 368 | typedef unsigned char Byte; /* 8 bits */ 369 | #endif 370 | typedef unsigned int uInt; /* 16 bits or more */ 371 | typedef unsigned long uLong; /* 32 bits or more */ 372 | 373 | #ifdef SMALL_MEDIUM 374 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 375 | # define Bytef Byte FAR 376 | #else 377 | typedef Byte FAR Bytef; 378 | #endif 379 | typedef char FAR charf; 380 | typedef int FAR intf; 381 | typedef uInt FAR uIntf; 382 | typedef uLong FAR uLongf; 383 | 384 | #ifdef STDC 385 | typedef void const *voidpc; 386 | typedef void FAR *voidpf; 387 | typedef void *voidp; 388 | #else 389 | typedef Byte const *voidpc; 390 | typedef Byte FAR *voidpf; 391 | typedef Byte *voidp; 392 | #endif 393 | 394 | #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) 395 | # include 396 | # if (UINT_MAX == 0xffffffffUL) 397 | # define Z_U4 unsigned 398 | # elif (ULONG_MAX == 0xffffffffUL) 399 | # define Z_U4 unsigned long 400 | # elif (USHRT_MAX == 0xffffffffUL) 401 | # define Z_U4 unsigned short 402 | # endif 403 | #endif 404 | 405 | #ifdef Z_U4 406 | typedef Z_U4 z_crc_t; 407 | #else 408 | typedef unsigned long z_crc_t; 409 | #endif 410 | 411 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 412 | # define Z_HAVE_UNISTD_H 413 | #endif 414 | 415 | #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ 416 | # define Z_HAVE_STDARG_H 417 | #endif 418 | 419 | #ifdef STDC 420 | # ifndef Z_SOLO 421 | # include /* for off_t */ 422 | # endif 423 | #endif 424 | 425 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) 426 | # ifndef Z_SOLO 427 | # include /* for va_list */ 428 | # endif 429 | #endif 430 | 431 | #ifdef _WIN32 432 | # ifndef Z_SOLO 433 | # include /* for wchar_t */ 434 | # endif 435 | #endif 436 | 437 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 438 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 439 | * though the former does not conform to the LFS document), but considering 440 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 441 | * equivalently requesting no 64-bit operations 442 | */ 443 | #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 444 | # undef _LARGEFILE64_SOURCE 445 | #endif 446 | 447 | #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) 448 | # define Z_HAVE_UNISTD_H 449 | #endif 450 | #ifndef Z_SOLO 451 | # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 452 | # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ 453 | # ifdef VMS 454 | # include /* for off_t */ 455 | # endif 456 | # ifndef z_off_t 457 | # define z_off_t off_t 458 | # endif 459 | # endif 460 | #endif 461 | 462 | #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 463 | # define Z_LFS64 464 | #endif 465 | 466 | #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) 467 | # define Z_LARGE64 468 | #endif 469 | 470 | #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) 471 | # define Z_WANT64 472 | #endif 473 | 474 | #if !defined(SEEK_SET) && !defined(Z_SOLO) 475 | # define SEEK_SET 0 /* Seek from beginning of file. */ 476 | # define SEEK_CUR 1 /* Seek from current position. */ 477 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 478 | #endif 479 | 480 | #ifndef z_off_t 481 | # define z_off_t long 482 | #endif 483 | 484 | #if !defined(_WIN32) && defined(Z_LARGE64) 485 | # define z_off64_t off64_t 486 | #else 487 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) 488 | # define z_off64_t __int64 489 | # else 490 | # define z_off64_t z_off_t 491 | # endif 492 | #endif 493 | 494 | /* MVS linker does not support external names larger than 8 bytes */ 495 | #if defined(__MVS__) 496 | #pragma map(deflateInit_,"DEIN") 497 | #pragma map(deflateInit2_,"DEIN2") 498 | #pragma map(deflateEnd,"DEEND") 499 | #pragma map(deflateBound,"DEBND") 500 | #pragma map(inflateInit_,"ININ") 501 | #pragma map(inflateInit2_,"ININ2") 502 | #pragma map(inflateEnd,"INEND") 503 | #pragma map(inflateSync,"INSY") 504 | #pragma map(inflateSetDictionary,"INSEDI") 505 | #pragma map(compressBound,"CMBND") 506 | #pragma map(inflate_table,"INTABL") 507 | #pragma map(inflate_fast,"INFA") 508 | #pragma map(inflate_copyright,"INCOPY") 509 | #endif 510 | 511 | #endif /* ZCONF_H */ 512 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/android-ifaddrs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995, 1999 3 | * Berkeley Software Design, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND 12 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 13 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 14 | * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE 15 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 16 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 17 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 19 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 20 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 21 | * SUCH DAMAGE. 22 | * 23 | * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp 24 | */ 25 | 26 | #ifndef _IFADDRS_H_ 27 | #define _IFADDRS_H_ 28 | 29 | struct ifaddrs { 30 | struct ifaddrs *ifa_next; 31 | char *ifa_name; 32 | unsigned int ifa_flags; 33 | struct sockaddr *ifa_addr; 34 | struct sockaddr *ifa_netmask; 35 | struct sockaddr *ifa_dstaddr; 36 | void *ifa_data; 37 | }; 38 | 39 | /* 40 | * This may have been defined in . Note that if is 41 | * to be included it must be included before this header file. 42 | */ 43 | #ifndef ifa_broadaddr 44 | #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 45 | #endif 46 | 47 | #include 48 | 49 | __BEGIN_DECLS 50 | extern int getifaddrs(struct ifaddrs **ifap); 51 | extern void freeifaddrs(struct ifaddrs *ifa); 52 | __END_DECLS 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/pthread-barrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, Kari Tristan Helgason 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any 5 | purpose with or without fee is hereby granted, provided that the above 6 | copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef _UV_PTHREAD_BARRIER_ 18 | #define _UV_PTHREAD_BARRIER_ 19 | #include 20 | #include 21 | #if !defined(__MVS__) 22 | #include /* sem_t */ 23 | #endif 24 | 25 | #define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 26 | 27 | /* 28 | * To maintain ABI compatibility with 29 | * libuv v1.x struct is padded according 30 | * to target platform 31 | */ 32 | #if defined(__ANDROID__) 33 | # define UV_BARRIER_STRUCT_PADDING \ 34 | sizeof(pthread_mutex_t) + \ 35 | sizeof(pthread_cond_t) + \ 36 | sizeof(unsigned int) - \ 37 | sizeof(void *) 38 | #elif defined(__APPLE__) 39 | # define UV_BARRIER_STRUCT_PADDING \ 40 | sizeof(pthread_mutex_t) + \ 41 | 2 * sizeof(sem_t) + \ 42 | 2 * sizeof(unsigned int) - \ 43 | sizeof(void *) 44 | #else 45 | # define UV_BARRIER_STRUCT_PADDING 0 46 | #endif 47 | 48 | typedef struct { 49 | pthread_mutex_t mutex; 50 | pthread_cond_t cond; 51 | unsigned threshold; 52 | unsigned in; 53 | unsigned out; 54 | } _uv_barrier; 55 | 56 | typedef struct { 57 | _uv_barrier* b; 58 | char _pad[UV_BARRIER_STRUCT_PADDING]; 59 | } pthread_barrier_t; 60 | 61 | int pthread_barrier_init(pthread_barrier_t* barrier, 62 | const void* barrier_attr, 63 | unsigned count); 64 | 65 | int pthread_barrier_wait(pthread_barrier_t* barrier); 66 | int pthread_barrier_destroy(pthread_barrier_t *barrier); 67 | 68 | #endif /* _UV_PTHREAD_BARRIER_ */ 69 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/stdint-msvc2008.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_STDINT_H_ // [ 37 | #define _MSC_STDINT_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include 44 | 45 | // For Visual Studio 6 in C++ mode and for many Visual Studio versions when 46 | // compiling for ARM we should wrap include with 'extern "C++" {}' 47 | // or compiler give many errors like this: 48 | // error C2733: second C linkage of overloaded function 'wmemchr' not allowed 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | # include 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | // Define _W64 macros to mark types changing their size, like intptr_t. 58 | #ifndef _W64 59 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 60 | # define _W64 __w64 61 | # else 62 | # define _W64 63 | # endif 64 | #endif 65 | 66 | 67 | // 7.18.1 Integer types 68 | 69 | // 7.18.1.1 Exact-width integer types 70 | 71 | // Visual Studio 6 and Embedded Visual C++ 4 doesn't 72 | // realize that, e.g. char has the same size as __int8 73 | // so we give up on __intX for them. 74 | #if (_MSC_VER < 1300) 75 | typedef signed char int8_t; 76 | typedef signed short int16_t; 77 | typedef signed int int32_t; 78 | typedef unsigned char uint8_t; 79 | typedef unsigned short uint16_t; 80 | typedef unsigned int uint32_t; 81 | #else 82 | typedef signed __int8 int8_t; 83 | typedef signed __int16 int16_t; 84 | typedef signed __int32 int32_t; 85 | typedef unsigned __int8 uint8_t; 86 | typedef unsigned __int16 uint16_t; 87 | typedef unsigned __int32 uint32_t; 88 | #endif 89 | typedef signed __int64 int64_t; 90 | typedef unsigned __int64 uint64_t; 91 | 92 | 93 | // 7.18.1.2 Minimum-width integer types 94 | typedef int8_t int_least8_t; 95 | typedef int16_t int_least16_t; 96 | typedef int32_t int_least32_t; 97 | typedef int64_t int_least64_t; 98 | typedef uint8_t uint_least8_t; 99 | typedef uint16_t uint_least16_t; 100 | typedef uint32_t uint_least32_t; 101 | typedef uint64_t uint_least64_t; 102 | 103 | // 7.18.1.3 Fastest minimum-width integer types 104 | typedef int8_t int_fast8_t; 105 | typedef int16_t int_fast16_t; 106 | typedef int32_t int_fast32_t; 107 | typedef int64_t int_fast64_t; 108 | typedef uint8_t uint_fast8_t; 109 | typedef uint16_t uint_fast16_t; 110 | typedef uint32_t uint_fast32_t; 111 | typedef uint64_t uint_fast64_t; 112 | 113 | // 7.18.1.4 Integer types capable of holding object pointers 114 | #ifdef _WIN64 // [ 115 | typedef signed __int64 intptr_t; 116 | typedef unsigned __int64 uintptr_t; 117 | #else // _WIN64 ][ 118 | typedef _W64 signed int intptr_t; 119 | typedef _W64 unsigned int uintptr_t; 120 | #endif // _WIN64 ] 121 | 122 | // 7.18.1.5 Greatest-width integer types 123 | typedef int64_t intmax_t; 124 | typedef uint64_t uintmax_t; 125 | 126 | 127 | // 7.18.2 Limits of specified-width integer types 128 | 129 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 130 | 131 | // 7.18.2.1 Limits of exact-width integer types 132 | #define INT8_MIN ((int8_t)_I8_MIN) 133 | #define INT8_MAX _I8_MAX 134 | #define INT16_MIN ((int16_t)_I16_MIN) 135 | #define INT16_MAX _I16_MAX 136 | #define INT32_MIN ((int32_t)_I32_MIN) 137 | #define INT32_MAX _I32_MAX 138 | #define INT64_MIN ((int64_t)_I64_MIN) 139 | #define INT64_MAX _I64_MAX 140 | #define UINT8_MAX _UI8_MAX 141 | #define UINT16_MAX _UI16_MAX 142 | #define UINT32_MAX _UI32_MAX 143 | #define UINT64_MAX _UI64_MAX 144 | 145 | // 7.18.2.2 Limits of minimum-width integer types 146 | #define INT_LEAST8_MIN INT8_MIN 147 | #define INT_LEAST8_MAX INT8_MAX 148 | #define INT_LEAST16_MIN INT16_MIN 149 | #define INT_LEAST16_MAX INT16_MAX 150 | #define INT_LEAST32_MIN INT32_MIN 151 | #define INT_LEAST32_MAX INT32_MAX 152 | #define INT_LEAST64_MIN INT64_MIN 153 | #define INT_LEAST64_MAX INT64_MAX 154 | #define UINT_LEAST8_MAX UINT8_MAX 155 | #define UINT_LEAST16_MAX UINT16_MAX 156 | #define UINT_LEAST32_MAX UINT32_MAX 157 | #define UINT_LEAST64_MAX UINT64_MAX 158 | 159 | // 7.18.2.3 Limits of fastest minimum-width integer types 160 | #define INT_FAST8_MIN INT8_MIN 161 | #define INT_FAST8_MAX INT8_MAX 162 | #define INT_FAST16_MIN INT16_MIN 163 | #define INT_FAST16_MAX INT16_MAX 164 | #define INT_FAST32_MIN INT32_MIN 165 | #define INT_FAST32_MAX INT32_MAX 166 | #define INT_FAST64_MIN INT64_MIN 167 | #define INT_FAST64_MAX INT64_MAX 168 | #define UINT_FAST8_MAX UINT8_MAX 169 | #define UINT_FAST16_MAX UINT16_MAX 170 | #define UINT_FAST32_MAX UINT32_MAX 171 | #define UINT_FAST64_MAX UINT64_MAX 172 | 173 | // 7.18.2.4 Limits of integer types capable of holding object pointers 174 | #ifdef _WIN64 // [ 175 | # define INTPTR_MIN INT64_MIN 176 | # define INTPTR_MAX INT64_MAX 177 | # define UINTPTR_MAX UINT64_MAX 178 | #else // _WIN64 ][ 179 | # define INTPTR_MIN INT32_MIN 180 | # define INTPTR_MAX INT32_MAX 181 | # define UINTPTR_MAX UINT32_MAX 182 | #endif // _WIN64 ] 183 | 184 | // 7.18.2.5 Limits of greatest-width integer types 185 | #define INTMAX_MIN INT64_MIN 186 | #define INTMAX_MAX INT64_MAX 187 | #define UINTMAX_MAX UINT64_MAX 188 | 189 | // 7.18.3 Limits of other integer types 190 | 191 | #ifdef _WIN64 // [ 192 | # define PTRDIFF_MIN _I64_MIN 193 | # define PTRDIFF_MAX _I64_MAX 194 | #else // _WIN64 ][ 195 | # define PTRDIFF_MIN _I32_MIN 196 | # define PTRDIFF_MAX _I32_MAX 197 | #endif // _WIN64 ] 198 | 199 | #define SIG_ATOMIC_MIN INT_MIN 200 | #define SIG_ATOMIC_MAX INT_MAX 201 | 202 | #ifndef SIZE_MAX // [ 203 | # ifdef _WIN64 // [ 204 | # define SIZE_MAX _UI64_MAX 205 | # else // _WIN64 ][ 206 | # define SIZE_MAX _UI32_MAX 207 | # endif // _WIN64 ] 208 | #endif // SIZE_MAX ] 209 | 210 | // WCHAR_MIN and WCHAR_MAX are also defined in 211 | #ifndef WCHAR_MIN // [ 212 | # define WCHAR_MIN 0 213 | #endif // WCHAR_MIN ] 214 | #ifndef WCHAR_MAX // [ 215 | # define WCHAR_MAX _UI16_MAX 216 | #endif // WCHAR_MAX ] 217 | 218 | #define WINT_MIN 0 219 | #define WINT_MAX _UI16_MAX 220 | 221 | #endif // __STDC_LIMIT_MACROS ] 222 | 223 | 224 | // 7.18.4 Limits of other integer types 225 | 226 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 227 | 228 | // 7.18.4.1 Macros for minimum-width integer constants 229 | 230 | #define INT8_C(val) val##i8 231 | #define INT16_C(val) val##i16 232 | #define INT32_C(val) val##i32 233 | #define INT64_C(val) val##i64 234 | 235 | #define UINT8_C(val) val##ui8 236 | #define UINT16_C(val) val##ui16 237 | #define UINT32_C(val) val##ui32 238 | #define UINT64_C(val) val##ui64 239 | 240 | // 7.18.4.2 Macros for greatest-width integer constants 241 | #define INTMAX_C INT64_C 242 | #define UINTMAX_C UINT64_C 243 | 244 | #endif // __STDC_CONSTANT_MACROS ] 245 | 246 | 247 | #endif // _MSC_STDINT_H_ ] 248 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-aix.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_AIX_H 23 | #define UV_AIX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | int fs_fd; \ 27 | 28 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 29 | uv__io_t event_watcher; \ 30 | char *dir_filename; \ 31 | 32 | #endif /* UV_AIX_H */ 33 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-bsd.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_BSD_H 23 | #define UV_BSD_H 24 | 25 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 26 | uv__io_t event_watcher; \ 27 | 28 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 29 | int rcount; \ 30 | int wcount; \ 31 | 32 | #define UV_HAVE_KQUEUE 1 33 | 34 | #endif /* UV_BSD_H */ 35 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-darwin.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_DARWIN_H 23 | #define UV_DARWIN_H 24 | 25 | #if defined(__APPLE__) && defined(__MACH__) 26 | # include 27 | # include 28 | # include 29 | # include 30 | # define UV_PLATFORM_SEM_T semaphore_t 31 | #endif 32 | 33 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 34 | int rcount; \ 35 | int wcount; \ 36 | 37 | #define UV_PLATFORM_LOOP_FIELDS \ 38 | uv_thread_t cf_thread; \ 39 | void* _cf_reserved; \ 40 | void* cf_state; \ 41 | uv_mutex_t cf_mutex; \ 42 | uv_sem_t cf_sem; \ 43 | void* cf_signals[2]; \ 44 | 45 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 46 | uv__io_t event_watcher; \ 47 | char* realpath; \ 48 | int realpath_len; \ 49 | int cf_flags; \ 50 | uv_async_t* cf_cb; \ 51 | void* cf_events[2]; \ 52 | void* cf_member[2]; \ 53 | int cf_error; \ 54 | uv_mutex_t cf_mutex; \ 55 | 56 | #define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ 57 | void* select; \ 58 | 59 | #define UV_HAVE_KQUEUE 1 60 | 61 | #endif /* UV_DARWIN_H */ 62 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-errno.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_ERRNO_H_ 23 | #define UV_ERRNO_H_ 24 | 25 | #include 26 | 27 | #define UV__EOF (-4095) 28 | #define UV__UNKNOWN (-4094) 29 | 30 | #define UV__EAI_ADDRFAMILY (-3000) 31 | #define UV__EAI_AGAIN (-3001) 32 | #define UV__EAI_BADFLAGS (-3002) 33 | #define UV__EAI_CANCELED (-3003) 34 | #define UV__EAI_FAIL (-3004) 35 | #define UV__EAI_FAMILY (-3005) 36 | #define UV__EAI_MEMORY (-3006) 37 | #define UV__EAI_NODATA (-3007) 38 | #define UV__EAI_NONAME (-3008) 39 | #define UV__EAI_OVERFLOW (-3009) 40 | #define UV__EAI_SERVICE (-3010) 41 | #define UV__EAI_SOCKTYPE (-3011) 42 | #define UV__EAI_BADHINTS (-3013) 43 | #define UV__EAI_PROTOCOL (-3014) 44 | 45 | /* Only map to the system errno on non-Windows platforms. It's apparently 46 | * a fairly common practice for Windows programmers to redefine errno codes. 47 | */ 48 | #if defined(E2BIG) && !defined(_WIN32) 49 | # define UV__E2BIG (-E2BIG) 50 | #else 51 | # define UV__E2BIG (-4093) 52 | #endif 53 | 54 | #if defined(EACCES) && !defined(_WIN32) 55 | # define UV__EACCES (-EACCES) 56 | #else 57 | # define UV__EACCES (-4092) 58 | #endif 59 | 60 | #if defined(EADDRINUSE) && !defined(_WIN32) 61 | # define UV__EADDRINUSE (-EADDRINUSE) 62 | #else 63 | # define UV__EADDRINUSE (-4091) 64 | #endif 65 | 66 | #if defined(EADDRNOTAVAIL) && !defined(_WIN32) 67 | # define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL) 68 | #else 69 | # define UV__EADDRNOTAVAIL (-4090) 70 | #endif 71 | 72 | #if defined(EAFNOSUPPORT) && !defined(_WIN32) 73 | # define UV__EAFNOSUPPORT (-EAFNOSUPPORT) 74 | #else 75 | # define UV__EAFNOSUPPORT (-4089) 76 | #endif 77 | 78 | #if defined(EAGAIN) && !defined(_WIN32) 79 | # define UV__EAGAIN (-EAGAIN) 80 | #else 81 | # define UV__EAGAIN (-4088) 82 | #endif 83 | 84 | #if defined(EALREADY) && !defined(_WIN32) 85 | # define UV__EALREADY (-EALREADY) 86 | #else 87 | # define UV__EALREADY (-4084) 88 | #endif 89 | 90 | #if defined(EBADF) && !defined(_WIN32) 91 | # define UV__EBADF (-EBADF) 92 | #else 93 | # define UV__EBADF (-4083) 94 | #endif 95 | 96 | #if defined(EBUSY) && !defined(_WIN32) 97 | # define UV__EBUSY (-EBUSY) 98 | #else 99 | # define UV__EBUSY (-4082) 100 | #endif 101 | 102 | #if defined(ECANCELED) && !defined(_WIN32) 103 | # define UV__ECANCELED (-ECANCELED) 104 | #else 105 | # define UV__ECANCELED (-4081) 106 | #endif 107 | 108 | #if defined(ECHARSET) && !defined(_WIN32) 109 | # define UV__ECHARSET (-ECHARSET) 110 | #else 111 | # define UV__ECHARSET (-4080) 112 | #endif 113 | 114 | #if defined(ECONNABORTED) && !defined(_WIN32) 115 | # define UV__ECONNABORTED (-ECONNABORTED) 116 | #else 117 | # define UV__ECONNABORTED (-4079) 118 | #endif 119 | 120 | #if defined(ECONNREFUSED) && !defined(_WIN32) 121 | # define UV__ECONNREFUSED (-ECONNREFUSED) 122 | #else 123 | # define UV__ECONNREFUSED (-4078) 124 | #endif 125 | 126 | #if defined(ECONNRESET) && !defined(_WIN32) 127 | # define UV__ECONNRESET (-ECONNRESET) 128 | #else 129 | # define UV__ECONNRESET (-4077) 130 | #endif 131 | 132 | #if defined(EDESTADDRREQ) && !defined(_WIN32) 133 | # define UV__EDESTADDRREQ (-EDESTADDRREQ) 134 | #else 135 | # define UV__EDESTADDRREQ (-4076) 136 | #endif 137 | 138 | #if defined(EEXIST) && !defined(_WIN32) 139 | # define UV__EEXIST (-EEXIST) 140 | #else 141 | # define UV__EEXIST (-4075) 142 | #endif 143 | 144 | #if defined(EFAULT) && !defined(_WIN32) 145 | # define UV__EFAULT (-EFAULT) 146 | #else 147 | # define UV__EFAULT (-4074) 148 | #endif 149 | 150 | #if defined(EHOSTUNREACH) && !defined(_WIN32) 151 | # define UV__EHOSTUNREACH (-EHOSTUNREACH) 152 | #else 153 | # define UV__EHOSTUNREACH (-4073) 154 | #endif 155 | 156 | #if defined(EINTR) && !defined(_WIN32) 157 | # define UV__EINTR (-EINTR) 158 | #else 159 | # define UV__EINTR (-4072) 160 | #endif 161 | 162 | #if defined(EINVAL) && !defined(_WIN32) 163 | # define UV__EINVAL (-EINVAL) 164 | #else 165 | # define UV__EINVAL (-4071) 166 | #endif 167 | 168 | #if defined(EIO) && !defined(_WIN32) 169 | # define UV__EIO (-EIO) 170 | #else 171 | # define UV__EIO (-4070) 172 | #endif 173 | 174 | #if defined(EISCONN) && !defined(_WIN32) 175 | # define UV__EISCONN (-EISCONN) 176 | #else 177 | # define UV__EISCONN (-4069) 178 | #endif 179 | 180 | #if defined(EISDIR) && !defined(_WIN32) 181 | # define UV__EISDIR (-EISDIR) 182 | #else 183 | # define UV__EISDIR (-4068) 184 | #endif 185 | 186 | #if defined(ELOOP) && !defined(_WIN32) 187 | # define UV__ELOOP (-ELOOP) 188 | #else 189 | # define UV__ELOOP (-4067) 190 | #endif 191 | 192 | #if defined(EMFILE) && !defined(_WIN32) 193 | # define UV__EMFILE (-EMFILE) 194 | #else 195 | # define UV__EMFILE (-4066) 196 | #endif 197 | 198 | #if defined(EMSGSIZE) && !defined(_WIN32) 199 | # define UV__EMSGSIZE (-EMSGSIZE) 200 | #else 201 | # define UV__EMSGSIZE (-4065) 202 | #endif 203 | 204 | #if defined(ENAMETOOLONG) && !defined(_WIN32) 205 | # define UV__ENAMETOOLONG (-ENAMETOOLONG) 206 | #else 207 | # define UV__ENAMETOOLONG (-4064) 208 | #endif 209 | 210 | #if defined(ENETDOWN) && !defined(_WIN32) 211 | # define UV__ENETDOWN (-ENETDOWN) 212 | #else 213 | # define UV__ENETDOWN (-4063) 214 | #endif 215 | 216 | #if defined(ENETUNREACH) && !defined(_WIN32) 217 | # define UV__ENETUNREACH (-ENETUNREACH) 218 | #else 219 | # define UV__ENETUNREACH (-4062) 220 | #endif 221 | 222 | #if defined(ENFILE) && !defined(_WIN32) 223 | # define UV__ENFILE (-ENFILE) 224 | #else 225 | # define UV__ENFILE (-4061) 226 | #endif 227 | 228 | #if defined(ENOBUFS) && !defined(_WIN32) 229 | # define UV__ENOBUFS (-ENOBUFS) 230 | #else 231 | # define UV__ENOBUFS (-4060) 232 | #endif 233 | 234 | #if defined(ENODEV) && !defined(_WIN32) 235 | # define UV__ENODEV (-ENODEV) 236 | #else 237 | # define UV__ENODEV (-4059) 238 | #endif 239 | 240 | #if defined(ENOENT) && !defined(_WIN32) 241 | # define UV__ENOENT (-ENOENT) 242 | #else 243 | # define UV__ENOENT (-4058) 244 | #endif 245 | 246 | #if defined(ENOMEM) && !defined(_WIN32) 247 | # define UV__ENOMEM (-ENOMEM) 248 | #else 249 | # define UV__ENOMEM (-4057) 250 | #endif 251 | 252 | #if defined(ENONET) && !defined(_WIN32) 253 | # define UV__ENONET (-ENONET) 254 | #else 255 | # define UV__ENONET (-4056) 256 | #endif 257 | 258 | #if defined(ENOSPC) && !defined(_WIN32) 259 | # define UV__ENOSPC (-ENOSPC) 260 | #else 261 | # define UV__ENOSPC (-4055) 262 | #endif 263 | 264 | #if defined(ENOSYS) && !defined(_WIN32) 265 | # define UV__ENOSYS (-ENOSYS) 266 | #else 267 | # define UV__ENOSYS (-4054) 268 | #endif 269 | 270 | #if defined(ENOTCONN) && !defined(_WIN32) 271 | # define UV__ENOTCONN (-ENOTCONN) 272 | #else 273 | # define UV__ENOTCONN (-4053) 274 | #endif 275 | 276 | #if defined(ENOTDIR) && !defined(_WIN32) 277 | # define UV__ENOTDIR (-ENOTDIR) 278 | #else 279 | # define UV__ENOTDIR (-4052) 280 | #endif 281 | 282 | #if defined(ENOTEMPTY) && !defined(_WIN32) 283 | # define UV__ENOTEMPTY (-ENOTEMPTY) 284 | #else 285 | # define UV__ENOTEMPTY (-4051) 286 | #endif 287 | 288 | #if defined(ENOTSOCK) && !defined(_WIN32) 289 | # define UV__ENOTSOCK (-ENOTSOCK) 290 | #else 291 | # define UV__ENOTSOCK (-4050) 292 | #endif 293 | 294 | #if defined(ENOTSUP) && !defined(_WIN32) 295 | # define UV__ENOTSUP (-ENOTSUP) 296 | #else 297 | # define UV__ENOTSUP (-4049) 298 | #endif 299 | 300 | #if defined(EPERM) && !defined(_WIN32) 301 | # define UV__EPERM (-EPERM) 302 | #else 303 | # define UV__EPERM (-4048) 304 | #endif 305 | 306 | #if defined(EPIPE) && !defined(_WIN32) 307 | # define UV__EPIPE (-EPIPE) 308 | #else 309 | # define UV__EPIPE (-4047) 310 | #endif 311 | 312 | #if defined(EPROTO) && !defined(_WIN32) 313 | # define UV__EPROTO (-EPROTO) 314 | #else 315 | # define UV__EPROTO (-4046) 316 | #endif 317 | 318 | #if defined(EPROTONOSUPPORT) && !defined(_WIN32) 319 | # define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT) 320 | #else 321 | # define UV__EPROTONOSUPPORT (-4045) 322 | #endif 323 | 324 | #if defined(EPROTOTYPE) && !defined(_WIN32) 325 | # define UV__EPROTOTYPE (-EPROTOTYPE) 326 | #else 327 | # define UV__EPROTOTYPE (-4044) 328 | #endif 329 | 330 | #if defined(EROFS) && !defined(_WIN32) 331 | # define UV__EROFS (-EROFS) 332 | #else 333 | # define UV__EROFS (-4043) 334 | #endif 335 | 336 | #if defined(ESHUTDOWN) && !defined(_WIN32) 337 | # define UV__ESHUTDOWN (-ESHUTDOWN) 338 | #else 339 | # define UV__ESHUTDOWN (-4042) 340 | #endif 341 | 342 | #if defined(ESPIPE) && !defined(_WIN32) 343 | # define UV__ESPIPE (-ESPIPE) 344 | #else 345 | # define UV__ESPIPE (-4041) 346 | #endif 347 | 348 | #if defined(ESRCH) && !defined(_WIN32) 349 | # define UV__ESRCH (-ESRCH) 350 | #else 351 | # define UV__ESRCH (-4040) 352 | #endif 353 | 354 | #if defined(ETIMEDOUT) && !defined(_WIN32) 355 | # define UV__ETIMEDOUT (-ETIMEDOUT) 356 | #else 357 | # define UV__ETIMEDOUT (-4039) 358 | #endif 359 | 360 | #if defined(ETXTBSY) && !defined(_WIN32) 361 | # define UV__ETXTBSY (-ETXTBSY) 362 | #else 363 | # define UV__ETXTBSY (-4038) 364 | #endif 365 | 366 | #if defined(EXDEV) && !defined(_WIN32) 367 | # define UV__EXDEV (-EXDEV) 368 | #else 369 | # define UV__EXDEV (-4037) 370 | #endif 371 | 372 | #if defined(EFBIG) && !defined(_WIN32) 373 | # define UV__EFBIG (-EFBIG) 374 | #else 375 | # define UV__EFBIG (-4036) 376 | #endif 377 | 378 | #if defined(ENOPROTOOPT) && !defined(_WIN32) 379 | # define UV__ENOPROTOOPT (-ENOPROTOOPT) 380 | #else 381 | # define UV__ENOPROTOOPT (-4035) 382 | #endif 383 | 384 | #if defined(ERANGE) && !defined(_WIN32) 385 | # define UV__ERANGE (-ERANGE) 386 | #else 387 | # define UV__ERANGE (-4034) 388 | #endif 389 | 390 | #if defined(ENXIO) && !defined(_WIN32) 391 | # define UV__ENXIO (-ENXIO) 392 | #else 393 | # define UV__ENXIO (-4033) 394 | #endif 395 | 396 | #if defined(EMLINK) && !defined(_WIN32) 397 | # define UV__EMLINK (-EMLINK) 398 | #else 399 | # define UV__EMLINK (-4032) 400 | #endif 401 | 402 | /* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is 403 | * defined. Fortunately, its value is always 64 so it's possible albeit 404 | * icky to hard-code it. 405 | */ 406 | #if defined(EHOSTDOWN) && !defined(_WIN32) 407 | # define UV__EHOSTDOWN (-EHOSTDOWN) 408 | #elif defined(__APPLE__) || \ 409 | defined(__DragonFly__) || \ 410 | defined(__FreeBSD__) || \ 411 | defined(__FreeBSD_kernel__) || \ 412 | defined(__NetBSD__) || \ 413 | defined(__OpenBSD__) 414 | # define UV__EHOSTDOWN (-64) 415 | #else 416 | # define UV__EHOSTDOWN (-4031) 417 | #endif 418 | 419 | #endif /* UV_ERRNO_H_ */ 420 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-linux.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_H 23 | #define UV_LINUX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | uv__io_t inotify_read_watcher; \ 27 | void* inotify_watchers; \ 28 | int inotify_fd; \ 29 | 30 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 31 | void* watchers[2]; \ 32 | int wd; \ 33 | 34 | #endif /* UV_LINUX_H */ 35 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-os390.h: -------------------------------------------------------------------------------- 1 | /* Copyright libuv project contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_MVS_H 23 | #define UV_MVS_H 24 | 25 | #define UV_PLATFORM_SEM_T int 26 | 27 | #define UV_PLATFORM_LOOP_FIELDS \ 28 | void* ep; \ 29 | 30 | #endif /* UV_MVS_H */ 31 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-posix.h: -------------------------------------------------------------------------------- 1 | /* Copyright libuv project contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_POSIX_H 23 | #define UV_POSIX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | struct pollfd* poll_fds; \ 27 | size_t poll_fds_used; \ 28 | size_t poll_fds_size; \ 29 | unsigned char poll_fds_iterating; \ 30 | 31 | #endif /* UV_POSIX_H */ 32 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-sunos.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_SUNOS_H 23 | #define UV_SUNOS_H 24 | 25 | #include 26 | #include 27 | 28 | /* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, 29 | * add the fs_event fields even when this version of SunOS doesn't support 30 | * file watching. 31 | */ 32 | #define UV_PLATFORM_LOOP_FIELDS \ 33 | uv__io_t fs_event_watcher; \ 34 | int fs_fd; \ 35 | 36 | #if defined(PORT_SOURCE_FILE) 37 | 38 | # define UV_PLATFORM_FS_EVENT_FIELDS \ 39 | file_obj_t fo; \ 40 | int fd; \ 41 | 42 | #endif /* defined(PORT_SOURCE_FILE) */ 43 | 44 | #endif /* UV_SUNOS_H */ 45 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-threadpool.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | /* 23 | * This file is private to libuv. It provides common functionality to both 24 | * Windows and Unix backends. 25 | */ 26 | 27 | #ifndef UV_THREADPOOL_H_ 28 | #define UV_THREADPOOL_H_ 29 | 30 | struct uv__work { 31 | void (*work)(struct uv__work *w); 32 | void (*done)(struct uv__work *w, int status); 33 | struct uv_loop_s* loop; 34 | void* wq[2]; 35 | }; 36 | 37 | #endif /* UV_THREADPOOL_H_ */ 38 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-unix.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_UNIX_H 23 | #define UV_UNIX_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | #if !defined(__MVS__) 40 | #include 41 | #endif 42 | #include 43 | #include 44 | 45 | #include "uv-threadpool.h" 46 | 47 | #if defined(__linux__) 48 | # include "uv-linux.h" 49 | #elif defined (__MVS__) 50 | # include "uv-os390.h" 51 | #elif defined(_AIX) 52 | # include "uv-aix.h" 53 | #elif defined(__sun) 54 | # include "uv-sunos.h" 55 | #elif defined(__APPLE__) 56 | # include "uv-darwin.h" 57 | #elif defined(__DragonFly__) || \ 58 | defined(__FreeBSD__) || \ 59 | defined(__FreeBSD_kernel__) || \ 60 | defined(__OpenBSD__) || \ 61 | defined(__NetBSD__) 62 | # include "uv-bsd.h" 63 | #elif defined(__CYGWIN__) || defined(__MSYS__) 64 | # include "uv-posix.h" 65 | #endif 66 | 67 | #ifndef PTHREAD_BARRIER_SERIAL_THREAD 68 | # include "pthread-barrier.h" 69 | #endif 70 | 71 | #ifndef NI_MAXHOST 72 | # define NI_MAXHOST 1025 73 | #endif 74 | 75 | #ifndef NI_MAXSERV 76 | # define NI_MAXSERV 32 77 | #endif 78 | 79 | #ifndef UV_IO_PRIVATE_PLATFORM_FIELDS 80 | # define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ 81 | #endif 82 | 83 | struct uv__io_s; 84 | struct uv_loop_s; 85 | 86 | typedef void (*uv__io_cb)(struct uv_loop_s* loop, 87 | struct uv__io_s* w, 88 | unsigned int events); 89 | typedef struct uv__io_s uv__io_t; 90 | 91 | struct uv__io_s { 92 | uv__io_cb cb; 93 | void* pending_queue[2]; 94 | void* watcher_queue[2]; 95 | unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ 96 | unsigned int events; /* Current event mask. */ 97 | int fd; 98 | UV_IO_PRIVATE_PLATFORM_FIELDS 99 | }; 100 | 101 | #ifndef UV_PLATFORM_SEM_T 102 | # define UV_PLATFORM_SEM_T sem_t 103 | #endif 104 | 105 | #ifndef UV_PLATFORM_LOOP_FIELDS 106 | # define UV_PLATFORM_LOOP_FIELDS /* empty */ 107 | #endif 108 | 109 | #ifndef UV_PLATFORM_FS_EVENT_FIELDS 110 | # define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ 111 | #endif 112 | 113 | #ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS 114 | # define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ 115 | #endif 116 | 117 | /* Note: May be cast to struct iovec. See writev(2). */ 118 | typedef struct uv_buf_t { 119 | char* base; 120 | size_t len; 121 | } uv_buf_t; 122 | 123 | typedef int uv_file; 124 | typedef int uv_os_sock_t; 125 | typedef int uv_os_fd_t; 126 | 127 | #define UV_ONCE_INIT PTHREAD_ONCE_INIT 128 | 129 | typedef pthread_once_t uv_once_t; 130 | typedef pthread_t uv_thread_t; 131 | typedef pthread_mutex_t uv_mutex_t; 132 | typedef pthread_rwlock_t uv_rwlock_t; 133 | typedef UV_PLATFORM_SEM_T uv_sem_t; 134 | typedef pthread_cond_t uv_cond_t; 135 | typedef pthread_key_t uv_key_t; 136 | typedef pthread_barrier_t uv_barrier_t; 137 | 138 | 139 | /* Platform-specific definitions for uv_spawn support. */ 140 | typedef gid_t uv_gid_t; 141 | typedef uid_t uv_uid_t; 142 | 143 | typedef struct dirent uv__dirent_t; 144 | 145 | #if defined(DT_UNKNOWN) 146 | # define HAVE_DIRENT_TYPES 147 | # if defined(DT_REG) 148 | # define UV__DT_FILE DT_REG 149 | # else 150 | # define UV__DT_FILE -1 151 | # endif 152 | # if defined(DT_DIR) 153 | # define UV__DT_DIR DT_DIR 154 | # else 155 | # define UV__DT_DIR -2 156 | # endif 157 | # if defined(DT_LNK) 158 | # define UV__DT_LINK DT_LNK 159 | # else 160 | # define UV__DT_LINK -3 161 | # endif 162 | # if defined(DT_FIFO) 163 | # define UV__DT_FIFO DT_FIFO 164 | # else 165 | # define UV__DT_FIFO -4 166 | # endif 167 | # if defined(DT_SOCK) 168 | # define UV__DT_SOCKET DT_SOCK 169 | # else 170 | # define UV__DT_SOCKET -5 171 | # endif 172 | # if defined(DT_CHR) 173 | # define UV__DT_CHAR DT_CHR 174 | # else 175 | # define UV__DT_CHAR -6 176 | # endif 177 | # if defined(DT_BLK) 178 | # define UV__DT_BLOCK DT_BLK 179 | # else 180 | # define UV__DT_BLOCK -7 181 | # endif 182 | #endif 183 | 184 | /* Platform-specific definitions for uv_dlopen support. */ 185 | #define UV_DYNAMIC /* empty */ 186 | 187 | typedef struct { 188 | void* handle; 189 | char* errmsg; 190 | } uv_lib_t; 191 | 192 | #define UV_LOOP_PRIVATE_FIELDS \ 193 | unsigned long flags; \ 194 | int backend_fd; \ 195 | void* pending_queue[2]; \ 196 | void* watcher_queue[2]; \ 197 | uv__io_t** watchers; \ 198 | unsigned int nwatchers; \ 199 | unsigned int nfds; \ 200 | void* wq[2]; \ 201 | uv_mutex_t wq_mutex; \ 202 | uv_async_t wq_async; \ 203 | uv_rwlock_t cloexec_lock; \ 204 | uv_handle_t* closing_handles; \ 205 | void* process_handles[2]; \ 206 | void* prepare_handles[2]; \ 207 | void* check_handles[2]; \ 208 | void* idle_handles[2]; \ 209 | void* async_handles[2]; \ 210 | void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ 211 | uv__io_t async_io_watcher; \ 212 | int async_wfd; \ 213 | struct { \ 214 | void* min; \ 215 | unsigned int nelts; \ 216 | } timer_heap; \ 217 | uint64_t timer_counter; \ 218 | uint64_t time; \ 219 | int signal_pipefd[2]; \ 220 | uv__io_t signal_io_watcher; \ 221 | uv_signal_t child_watcher; \ 222 | int emfile_fd; \ 223 | UV_PLATFORM_LOOP_FIELDS \ 224 | 225 | #define UV_REQ_TYPE_PRIVATE /* empty */ 226 | 227 | #define UV_REQ_PRIVATE_FIELDS /* empty */ 228 | 229 | #define UV_PRIVATE_REQ_TYPES /* empty */ 230 | 231 | #define UV_WRITE_PRIVATE_FIELDS \ 232 | void* queue[2]; \ 233 | unsigned int write_index; \ 234 | uv_buf_t* bufs; \ 235 | unsigned int nbufs; \ 236 | int error; \ 237 | uv_buf_t bufsml[4]; \ 238 | 239 | #define UV_CONNECT_PRIVATE_FIELDS \ 240 | void* queue[2]; \ 241 | 242 | #define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ 243 | 244 | #define UV_UDP_SEND_PRIVATE_FIELDS \ 245 | void* queue[2]; \ 246 | struct sockaddr_storage addr; \ 247 | unsigned int nbufs; \ 248 | uv_buf_t* bufs; \ 249 | ssize_t status; \ 250 | uv_udp_send_cb send_cb; \ 251 | uv_buf_t bufsml[4]; \ 252 | 253 | #define UV_HANDLE_PRIVATE_FIELDS \ 254 | uv_handle_t* next_closing; \ 255 | unsigned int flags; \ 256 | 257 | #define UV_STREAM_PRIVATE_FIELDS \ 258 | uv_connect_t *connect_req; \ 259 | uv_shutdown_t *shutdown_req; \ 260 | uv__io_t io_watcher; \ 261 | void* write_queue[2]; \ 262 | void* write_completed_queue[2]; \ 263 | uv_connection_cb connection_cb; \ 264 | int delayed_error; \ 265 | int accepted_fd; \ 266 | void* queued_fds; \ 267 | UV_STREAM_PRIVATE_PLATFORM_FIELDS \ 268 | 269 | #define UV_TCP_PRIVATE_FIELDS /* empty */ 270 | 271 | #define UV_UDP_PRIVATE_FIELDS \ 272 | uv_alloc_cb alloc_cb; \ 273 | uv_udp_recv_cb recv_cb; \ 274 | uv__io_t io_watcher; \ 275 | void* write_queue[2]; \ 276 | void* write_completed_queue[2]; \ 277 | 278 | #define UV_PIPE_PRIVATE_FIELDS \ 279 | const char* pipe_fname; /* strdup'ed */ 280 | 281 | #define UV_POLL_PRIVATE_FIELDS \ 282 | uv__io_t io_watcher; 283 | 284 | #define UV_PREPARE_PRIVATE_FIELDS \ 285 | uv_prepare_cb prepare_cb; \ 286 | void* queue[2]; \ 287 | 288 | #define UV_CHECK_PRIVATE_FIELDS \ 289 | uv_check_cb check_cb; \ 290 | void* queue[2]; \ 291 | 292 | #define UV_IDLE_PRIVATE_FIELDS \ 293 | uv_idle_cb idle_cb; \ 294 | void* queue[2]; \ 295 | 296 | #define UV_ASYNC_PRIVATE_FIELDS \ 297 | uv_async_cb async_cb; \ 298 | void* queue[2]; \ 299 | int pending; \ 300 | 301 | #define UV_TIMER_PRIVATE_FIELDS \ 302 | uv_timer_cb timer_cb; \ 303 | void* heap_node[3]; \ 304 | uint64_t timeout; \ 305 | uint64_t repeat; \ 306 | uint64_t start_id; 307 | 308 | #define UV_GETADDRINFO_PRIVATE_FIELDS \ 309 | struct uv__work work_req; \ 310 | uv_getaddrinfo_cb cb; \ 311 | struct addrinfo* hints; \ 312 | char* hostname; \ 313 | char* service; \ 314 | struct addrinfo* addrinfo; \ 315 | int retcode; 316 | 317 | #define UV_GETNAMEINFO_PRIVATE_FIELDS \ 318 | struct uv__work work_req; \ 319 | uv_getnameinfo_cb getnameinfo_cb; \ 320 | struct sockaddr_storage storage; \ 321 | int flags; \ 322 | char host[NI_MAXHOST]; \ 323 | char service[NI_MAXSERV]; \ 324 | int retcode; 325 | 326 | #define UV_PROCESS_PRIVATE_FIELDS \ 327 | void* queue[2]; \ 328 | int status; \ 329 | 330 | #define UV_FS_PRIVATE_FIELDS \ 331 | const char *new_path; \ 332 | uv_file file; \ 333 | int flags; \ 334 | mode_t mode; \ 335 | unsigned int nbufs; \ 336 | uv_buf_t* bufs; \ 337 | off_t off; \ 338 | uv_uid_t uid; \ 339 | uv_gid_t gid; \ 340 | double atime; \ 341 | double mtime; \ 342 | struct uv__work work_req; \ 343 | uv_buf_t bufsml[4]; \ 344 | 345 | #define UV_WORK_PRIVATE_FIELDS \ 346 | struct uv__work work_req; 347 | 348 | #define UV_TTY_PRIVATE_FIELDS \ 349 | struct termios orig_termios; \ 350 | int mode; 351 | 352 | #define UV_SIGNAL_PRIVATE_FIELDS \ 353 | /* RB_ENTRY(uv_signal_s) tree_entry; */ \ 354 | struct { \ 355 | struct uv_signal_s* rbe_left; \ 356 | struct uv_signal_s* rbe_right; \ 357 | struct uv_signal_s* rbe_parent; \ 358 | int rbe_color; \ 359 | } tree_entry; \ 360 | /* Use two counters here so we don have to fiddle with atomics. */ \ 361 | unsigned int caught_signals; \ 362 | unsigned int dispatched_signals; 363 | 364 | #define UV_FS_EVENT_PRIVATE_FIELDS \ 365 | uv_fs_event_cb cb; \ 366 | UV_PLATFORM_FS_EVENT_FIELDS \ 367 | 368 | #endif /* UV_UNIX_H */ 369 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_VERSION_H 23 | #define UV_VERSION_H 24 | 25 | /* 26 | * Versions with the same major number are ABI stable. API is allowed to 27 | * evolve between minor releases, but only in a backwards compatible way. 28 | * Make sure you update the -soname directives in configure.ac 29 | * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but 30 | * not UV_VERSION_PATCH.) 31 | */ 32 | 33 | #define UV_VERSION_MAJOR 1 34 | #define UV_VERSION_MINOR 13 35 | #define UV_VERSION_PATCH 1 36 | #define UV_VERSION_IS_RELEASE 1 37 | #define UV_VERSION_SUFFIX "" 38 | 39 | #define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ 40 | (UV_VERSION_MINOR << 8) | \ 41 | (UV_VERSION_PATCH)) 42 | 43 | #endif /* UV_VERSION_H */ 44 | -------------------------------------------------------------------------------- /curl_multi/libuv/include/uv-win.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef _WIN32_WINNT 23 | # define _WIN32_WINNT 0x0502 24 | #endif 25 | 26 | #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) 27 | typedef intptr_t ssize_t; 28 | # define _SSIZE_T_ 29 | # define _SSIZE_T_DEFINED 30 | #endif 31 | 32 | #include 33 | 34 | #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) 35 | typedef struct pollfd { 36 | SOCKET fd; 37 | short events; 38 | short revents; 39 | } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; 40 | #endif 41 | 42 | #ifndef LOCALE_INVARIANT 43 | # define LOCALE_INVARIANT 0x007f 44 | #endif 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | #if defined(_MSC_VER) && _MSC_VER < 1600 56 | # include "stdint-msvc2008.h" 57 | #else 58 | # include 59 | #endif 60 | 61 | #include "tree.h" 62 | #include "uv-threadpool.h" 63 | 64 | #define MAX_PIPENAME_LEN 256 65 | 66 | #ifndef S_IFLNK 67 | # define S_IFLNK 0xA000 68 | #endif 69 | 70 | /* Additional signals supported by uv_signal and or uv_kill. The CRT defines 71 | * the following signals already: 72 | * 73 | * #define SIGINT 2 74 | * #define SIGILL 4 75 | * #define SIGABRT_COMPAT 6 76 | * #define SIGFPE 8 77 | * #define SIGSEGV 11 78 | * #define SIGTERM 15 79 | * #define SIGBREAK 21 80 | * #define SIGABRT 22 81 | * 82 | * The additional signals have values that are common on other Unix 83 | * variants (Linux and Darwin) 84 | */ 85 | #define SIGHUP 1 86 | #define SIGKILL 9 87 | #define SIGWINCH 28 88 | 89 | /* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ 90 | /* unix-like platforms. However MinGW doesn't define it, so we do. */ 91 | #ifndef SIGABRT_COMPAT 92 | # define SIGABRT_COMPAT 6 93 | #endif 94 | 95 | /* 96 | * Guids and typedefs for winsock extension functions 97 | * Mingw32 doesn't have these :-( 98 | */ 99 | #ifndef WSAID_ACCEPTEX 100 | # define WSAID_ACCEPTEX \ 101 | {0xb5367df1, 0xcbac, 0x11cf, \ 102 | {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 103 | 104 | # define WSAID_CONNECTEX \ 105 | {0x25a207b9, 0xddf3, 0x4660, \ 106 | {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} 107 | 108 | # define WSAID_GETACCEPTEXSOCKADDRS \ 109 | {0xb5367df2, 0xcbac, 0x11cf, \ 110 | {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 111 | 112 | # define WSAID_DISCONNECTEX \ 113 | {0x7fda2e11, 0x8630, 0x436f, \ 114 | {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} 115 | 116 | # define WSAID_TRANSMITFILE \ 117 | {0xb5367df0, 0xcbac, 0x11cf, \ 118 | {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 119 | 120 | typedef BOOL (PASCAL *LPFN_ACCEPTEX) 121 | (SOCKET sListenSocket, 122 | SOCKET sAcceptSocket, 123 | PVOID lpOutputBuffer, 124 | DWORD dwReceiveDataLength, 125 | DWORD dwLocalAddressLength, 126 | DWORD dwRemoteAddressLength, 127 | LPDWORD lpdwBytesReceived, 128 | LPOVERLAPPED lpOverlapped); 129 | 130 | typedef BOOL (PASCAL *LPFN_CONNECTEX) 131 | (SOCKET s, 132 | const struct sockaddr* name, 133 | int namelen, 134 | PVOID lpSendBuffer, 135 | DWORD dwSendDataLength, 136 | LPDWORD lpdwBytesSent, 137 | LPOVERLAPPED lpOverlapped); 138 | 139 | typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) 140 | (PVOID lpOutputBuffer, 141 | DWORD dwReceiveDataLength, 142 | DWORD dwLocalAddressLength, 143 | DWORD dwRemoteAddressLength, 144 | LPSOCKADDR* LocalSockaddr, 145 | LPINT LocalSockaddrLength, 146 | LPSOCKADDR* RemoteSockaddr, 147 | LPINT RemoteSockaddrLength); 148 | 149 | typedef BOOL (PASCAL *LPFN_DISCONNECTEX) 150 | (SOCKET hSocket, 151 | LPOVERLAPPED lpOverlapped, 152 | DWORD dwFlags, 153 | DWORD reserved); 154 | 155 | typedef BOOL (PASCAL *LPFN_TRANSMITFILE) 156 | (SOCKET hSocket, 157 | HANDLE hFile, 158 | DWORD nNumberOfBytesToWrite, 159 | DWORD nNumberOfBytesPerSend, 160 | LPOVERLAPPED lpOverlapped, 161 | LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, 162 | DWORD dwFlags); 163 | 164 | typedef PVOID RTL_SRWLOCK; 165 | typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; 166 | #endif 167 | 168 | typedef int (WSAAPI* LPFN_WSARECV) 169 | (SOCKET socket, 170 | LPWSABUF buffers, 171 | DWORD buffer_count, 172 | LPDWORD bytes, 173 | LPDWORD flags, 174 | LPWSAOVERLAPPED overlapped, 175 | LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); 176 | 177 | typedef int (WSAAPI* LPFN_WSARECVFROM) 178 | (SOCKET socket, 179 | LPWSABUF buffers, 180 | DWORD buffer_count, 181 | LPDWORD bytes, 182 | LPDWORD flags, 183 | struct sockaddr* addr, 184 | LPINT addr_len, 185 | LPWSAOVERLAPPED overlapped, 186 | LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); 187 | 188 | #ifndef _NTDEF_ 189 | typedef LONG NTSTATUS; 190 | typedef NTSTATUS *PNTSTATUS; 191 | #endif 192 | 193 | #ifndef RTL_CONDITION_VARIABLE_INIT 194 | typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; 195 | #endif 196 | 197 | typedef struct _AFD_POLL_HANDLE_INFO { 198 | HANDLE Handle; 199 | ULONG Events; 200 | NTSTATUS Status; 201 | } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; 202 | 203 | typedef struct _AFD_POLL_INFO { 204 | LARGE_INTEGER Timeout; 205 | ULONG NumberOfHandles; 206 | ULONG Exclusive; 207 | AFD_POLL_HANDLE_INFO Handles[1]; 208 | } AFD_POLL_INFO, *PAFD_POLL_INFO; 209 | 210 | #define UV_MSAFD_PROVIDER_COUNT 3 211 | 212 | 213 | /** 214 | * It should be possible to cast uv_buf_t[] to WSABUF[] 215 | * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx 216 | */ 217 | typedef struct uv_buf_t { 218 | ULONG len; 219 | char* base; 220 | } uv_buf_t; 221 | 222 | typedef int uv_file; 223 | typedef SOCKET uv_os_sock_t; 224 | typedef HANDLE uv_os_fd_t; 225 | 226 | typedef HANDLE uv_thread_t; 227 | 228 | typedef HANDLE uv_sem_t; 229 | 230 | typedef CRITICAL_SECTION uv_mutex_t; 231 | 232 | /* This condition variable implementation is based on the SetEvent solution 233 | * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html 234 | * We could not use the SignalObjectAndWait solution (section 3.4) because 235 | * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and 236 | * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. 237 | */ 238 | 239 | typedef union { 240 | CONDITION_VARIABLE cond_var; 241 | struct { 242 | unsigned int waiters_count; 243 | CRITICAL_SECTION waiters_count_lock; 244 | HANDLE signal_event; 245 | HANDLE broadcast_event; 246 | } fallback; 247 | } uv_cond_t; 248 | 249 | typedef union { 250 | struct { 251 | unsigned int num_readers_; 252 | CRITICAL_SECTION num_readers_lock_; 253 | HANDLE write_semaphore_; 254 | } state_; 255 | /* TODO: remove me in v2.x. */ 256 | struct { 257 | SRWLOCK unused_; 258 | } unused1_; 259 | /* TODO: remove me in v2.x. */ 260 | struct { 261 | uv_mutex_t unused1_; 262 | uv_mutex_t unused2_; 263 | } unused2_; 264 | } uv_rwlock_t; 265 | 266 | typedef struct { 267 | unsigned int n; 268 | unsigned int count; 269 | uv_mutex_t mutex; 270 | uv_sem_t turnstile1; 271 | uv_sem_t turnstile2; 272 | } uv_barrier_t; 273 | 274 | typedef struct { 275 | DWORD tls_index; 276 | } uv_key_t; 277 | 278 | #define UV_ONCE_INIT { 0, NULL } 279 | 280 | typedef struct uv_once_s { 281 | unsigned char ran; 282 | HANDLE event; 283 | } uv_once_t; 284 | 285 | /* Platform-specific definitions for uv_spawn support. */ 286 | typedef unsigned char uv_uid_t; 287 | typedef unsigned char uv_gid_t; 288 | 289 | typedef struct uv__dirent_s { 290 | int d_type; 291 | char d_name[1]; 292 | } uv__dirent_t; 293 | 294 | #define HAVE_DIRENT_TYPES 295 | #define UV__DT_DIR UV_DIRENT_DIR 296 | #define UV__DT_FILE UV_DIRENT_FILE 297 | #define UV__DT_LINK UV_DIRENT_LINK 298 | #define UV__DT_FIFO UV_DIRENT_FIFO 299 | #define UV__DT_SOCKET UV_DIRENT_SOCKET 300 | #define UV__DT_CHAR UV_DIRENT_CHAR 301 | #define UV__DT_BLOCK UV_DIRENT_BLOCK 302 | 303 | /* Platform-specific definitions for uv_dlopen support. */ 304 | #define UV_DYNAMIC FAR WINAPI 305 | typedef struct { 306 | HMODULE handle; 307 | char* errmsg; 308 | } uv_lib_t; 309 | 310 | RB_HEAD(uv_timer_tree_s, uv_timer_s); 311 | 312 | #define UV_LOOP_PRIVATE_FIELDS \ 313 | /* The loop's I/O completion port */ \ 314 | HANDLE iocp; \ 315 | /* The current time according to the event loop. in msecs. */ \ 316 | uint64_t time; \ 317 | /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ 318 | /* is empty, tail_ is NULL. If there is only one item, */ \ 319 | /* tail_->next_req == tail_ */ \ 320 | uv_req_t* pending_reqs_tail; \ 321 | /* Head of a single-linked list of closed handles */ \ 322 | uv_handle_t* endgame_handles; \ 323 | /* The head of the timers tree */ \ 324 | struct uv_timer_tree_s timers; \ 325 | /* Lists of active loop (prepare / check / idle) watchers */ \ 326 | uv_prepare_t* prepare_handles; \ 327 | uv_check_t* check_handles; \ 328 | uv_idle_t* idle_handles; \ 329 | /* This pointer will refer to the prepare/check/idle handle whose */ \ 330 | /* callback is scheduled to be called next. This is needed to allow */ \ 331 | /* safe removal from one of the lists above while that list being */ \ 332 | /* iterated over. */ \ 333 | uv_prepare_t* next_prepare_handle; \ 334 | uv_check_t* next_check_handle; \ 335 | uv_idle_t* next_idle_handle; \ 336 | /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ 337 | SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ 338 | /* Counter to keep track of active tcp streams */ \ 339 | unsigned int active_tcp_streams; \ 340 | /* Counter to keep track of active udp streams */ \ 341 | unsigned int active_udp_streams; \ 342 | /* Counter to started timer */ \ 343 | uint64_t timer_counter; \ 344 | /* Threadpool */ \ 345 | void* wq[2]; \ 346 | uv_mutex_t wq_mutex; \ 347 | uv_async_t wq_async; 348 | 349 | #define UV_REQ_TYPE_PRIVATE \ 350 | /* TODO: remove the req suffix */ \ 351 | UV_ACCEPT, \ 352 | UV_FS_EVENT_REQ, \ 353 | UV_POLL_REQ, \ 354 | UV_PROCESS_EXIT, \ 355 | UV_READ, \ 356 | UV_UDP_RECV, \ 357 | UV_WAKEUP, \ 358 | UV_SIGNAL_REQ, 359 | 360 | #define UV_REQ_PRIVATE_FIELDS \ 361 | union { \ 362 | /* Used by I/O operations */ \ 363 | struct { \ 364 | OVERLAPPED overlapped; \ 365 | size_t queued_bytes; \ 366 | } io; \ 367 | } u; \ 368 | struct uv_req_s* next_req; 369 | 370 | #define UV_WRITE_PRIVATE_FIELDS \ 371 | int ipc_header; \ 372 | uv_buf_t write_buffer; \ 373 | HANDLE event_handle; \ 374 | HANDLE wait_handle; 375 | 376 | #define UV_CONNECT_PRIVATE_FIELDS \ 377 | /* empty */ 378 | 379 | #define UV_SHUTDOWN_PRIVATE_FIELDS \ 380 | /* empty */ 381 | 382 | #define UV_UDP_SEND_PRIVATE_FIELDS \ 383 | /* empty */ 384 | 385 | #define UV_PRIVATE_REQ_TYPES \ 386 | typedef struct uv_pipe_accept_s { \ 387 | UV_REQ_FIELDS \ 388 | HANDLE pipeHandle; \ 389 | struct uv_pipe_accept_s* next_pending; \ 390 | } uv_pipe_accept_t; \ 391 | \ 392 | typedef struct uv_tcp_accept_s { \ 393 | UV_REQ_FIELDS \ 394 | SOCKET accept_socket; \ 395 | char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ 396 | HANDLE event_handle; \ 397 | HANDLE wait_handle; \ 398 | struct uv_tcp_accept_s* next_pending; \ 399 | } uv_tcp_accept_t; \ 400 | \ 401 | typedef struct uv_read_s { \ 402 | UV_REQ_FIELDS \ 403 | HANDLE event_handle; \ 404 | HANDLE wait_handle; \ 405 | } uv_read_t; 406 | 407 | #define uv_stream_connection_fields \ 408 | unsigned int write_reqs_pending; \ 409 | uv_shutdown_t* shutdown_req; 410 | 411 | #define uv_stream_server_fields \ 412 | uv_connection_cb connection_cb; 413 | 414 | #define UV_STREAM_PRIVATE_FIELDS \ 415 | unsigned int reqs_pending; \ 416 | int activecnt; \ 417 | uv_read_t read_req; \ 418 | union { \ 419 | struct { uv_stream_connection_fields } conn; \ 420 | struct { uv_stream_server_fields } serv; \ 421 | } stream; 422 | 423 | #define uv_tcp_server_fields \ 424 | uv_tcp_accept_t* accept_reqs; \ 425 | unsigned int processed_accepts; \ 426 | uv_tcp_accept_t* pending_accepts; \ 427 | LPFN_ACCEPTEX func_acceptex; 428 | 429 | #define uv_tcp_connection_fields \ 430 | uv_buf_t read_buffer; \ 431 | LPFN_CONNECTEX func_connectex; 432 | 433 | #define UV_TCP_PRIVATE_FIELDS \ 434 | SOCKET socket; \ 435 | int delayed_error; \ 436 | union { \ 437 | struct { uv_tcp_server_fields } serv; \ 438 | struct { uv_tcp_connection_fields } conn; \ 439 | } tcp; 440 | 441 | #define UV_UDP_PRIVATE_FIELDS \ 442 | SOCKET socket; \ 443 | unsigned int reqs_pending; \ 444 | int activecnt; \ 445 | uv_req_t recv_req; \ 446 | uv_buf_t recv_buffer; \ 447 | struct sockaddr_storage recv_from; \ 448 | int recv_from_len; \ 449 | uv_udp_recv_cb recv_cb; \ 450 | uv_alloc_cb alloc_cb; \ 451 | LPFN_WSARECV func_wsarecv; \ 452 | LPFN_WSARECVFROM func_wsarecvfrom; 453 | 454 | #define uv_pipe_server_fields \ 455 | int pending_instances; \ 456 | uv_pipe_accept_t* accept_reqs; \ 457 | uv_pipe_accept_t* pending_accepts; 458 | 459 | #define uv_pipe_connection_fields \ 460 | uv_timer_t* eof_timer; \ 461 | uv_write_t ipc_header_write_req; \ 462 | int ipc_pid; \ 463 | uint64_t remaining_ipc_rawdata_bytes; \ 464 | struct { \ 465 | void* queue[2]; \ 466 | int queue_len; \ 467 | } pending_ipc_info; \ 468 | uv_write_t* non_overlapped_writes_tail; \ 469 | uv_mutex_t readfile_mutex; \ 470 | volatile HANDLE readfile_thread; 471 | 472 | #define UV_PIPE_PRIVATE_FIELDS \ 473 | HANDLE handle; \ 474 | WCHAR* name; \ 475 | union { \ 476 | struct { uv_pipe_server_fields } serv; \ 477 | struct { uv_pipe_connection_fields } conn; \ 478 | } pipe; 479 | 480 | /* TODO: put the parser states in an union - TTY handles are always */ 481 | /* half-duplex so read-state can safely overlap write-state. */ 482 | #define UV_TTY_PRIVATE_FIELDS \ 483 | HANDLE handle; \ 484 | union { \ 485 | struct { \ 486 | /* Used for readable TTY handles */ \ 487 | /* TODO: remove me in v2.x. */ \ 488 | HANDLE unused_; \ 489 | uv_buf_t read_line_buffer; \ 490 | HANDLE read_raw_wait; \ 491 | /* Fields used for translating win keystrokes into vt100 characters */ \ 492 | char last_key[8]; \ 493 | unsigned char last_key_offset; \ 494 | unsigned char last_key_len; \ 495 | WCHAR last_utf16_high_surrogate; \ 496 | INPUT_RECORD last_input_record; \ 497 | } rd; \ 498 | struct { \ 499 | /* Used for writable TTY handles */ \ 500 | /* utf8-to-utf16 conversion state */ \ 501 | unsigned int utf8_codepoint; \ 502 | unsigned char utf8_bytes_left; \ 503 | /* eol conversion state */ \ 504 | unsigned char previous_eol; \ 505 | /* ansi parser state */ \ 506 | unsigned char ansi_parser_state; \ 507 | unsigned char ansi_csi_argc; \ 508 | unsigned short ansi_csi_argv[4]; \ 509 | COORD saved_position; \ 510 | WORD saved_attributes; \ 511 | } wr; \ 512 | } tty; 513 | 514 | #define UV_POLL_PRIVATE_FIELDS \ 515 | SOCKET socket; \ 516 | /* Used in fast mode */ \ 517 | SOCKET peer_socket; \ 518 | AFD_POLL_INFO afd_poll_info_1; \ 519 | AFD_POLL_INFO afd_poll_info_2; \ 520 | /* Used in fast and slow mode. */ \ 521 | uv_req_t poll_req_1; \ 522 | uv_req_t poll_req_2; \ 523 | unsigned char submitted_events_1; \ 524 | unsigned char submitted_events_2; \ 525 | unsigned char mask_events_1; \ 526 | unsigned char mask_events_2; \ 527 | unsigned char events; 528 | 529 | #define UV_TIMER_PRIVATE_FIELDS \ 530 | RB_ENTRY(uv_timer_s) tree_entry; \ 531 | uint64_t due; \ 532 | uint64_t repeat; \ 533 | uint64_t start_id; \ 534 | uv_timer_cb timer_cb; 535 | 536 | #define UV_ASYNC_PRIVATE_FIELDS \ 537 | struct uv_req_s async_req; \ 538 | uv_async_cb async_cb; \ 539 | /* char to avoid alignment issues */ \ 540 | char volatile async_sent; 541 | 542 | #define UV_PREPARE_PRIVATE_FIELDS \ 543 | uv_prepare_t* prepare_prev; \ 544 | uv_prepare_t* prepare_next; \ 545 | uv_prepare_cb prepare_cb; 546 | 547 | #define UV_CHECK_PRIVATE_FIELDS \ 548 | uv_check_t* check_prev; \ 549 | uv_check_t* check_next; \ 550 | uv_check_cb check_cb; 551 | 552 | #define UV_IDLE_PRIVATE_FIELDS \ 553 | uv_idle_t* idle_prev; \ 554 | uv_idle_t* idle_next; \ 555 | uv_idle_cb idle_cb; 556 | 557 | #define UV_HANDLE_PRIVATE_FIELDS \ 558 | uv_handle_t* endgame_next; \ 559 | unsigned int flags; 560 | 561 | #define UV_GETADDRINFO_PRIVATE_FIELDS \ 562 | struct uv__work work_req; \ 563 | uv_getaddrinfo_cb getaddrinfo_cb; \ 564 | void* alloc; \ 565 | WCHAR* node; \ 566 | WCHAR* service; \ 567 | /* The addrinfoW field is used to store a pointer to the hints, and */ \ 568 | /* later on to store the result of GetAddrInfoW. The final result will */ \ 569 | /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ 570 | struct addrinfoW* addrinfow; \ 571 | struct addrinfo* addrinfo; \ 572 | int retcode; 573 | 574 | #define UV_GETNAMEINFO_PRIVATE_FIELDS \ 575 | struct uv__work work_req; \ 576 | uv_getnameinfo_cb getnameinfo_cb; \ 577 | struct sockaddr_storage storage; \ 578 | int flags; \ 579 | char host[NI_MAXHOST]; \ 580 | char service[NI_MAXSERV]; \ 581 | int retcode; 582 | 583 | #define UV_PROCESS_PRIVATE_FIELDS \ 584 | struct uv_process_exit_s { \ 585 | UV_REQ_FIELDS \ 586 | } exit_req; \ 587 | BYTE* child_stdio_buffer; \ 588 | int exit_signal; \ 589 | HANDLE wait_handle; \ 590 | HANDLE process_handle; \ 591 | volatile char exit_cb_pending; 592 | 593 | #define UV_FS_PRIVATE_FIELDS \ 594 | struct uv__work work_req; \ 595 | int flags; \ 596 | DWORD sys_errno_; \ 597 | union { \ 598 | /* TODO: remove me in 0.9. */ \ 599 | WCHAR* pathw; \ 600 | int fd; \ 601 | } file; \ 602 | union { \ 603 | struct { \ 604 | int mode; \ 605 | WCHAR* new_pathw; \ 606 | int file_flags; \ 607 | int fd_out; \ 608 | unsigned int nbufs; \ 609 | uv_buf_t* bufs; \ 610 | int64_t offset; \ 611 | uv_buf_t bufsml[4]; \ 612 | } info; \ 613 | struct { \ 614 | double atime; \ 615 | double mtime; \ 616 | } time; \ 617 | } fs; 618 | 619 | #define UV_WORK_PRIVATE_FIELDS \ 620 | struct uv__work work_req; 621 | 622 | #define UV_FS_EVENT_PRIVATE_FIELDS \ 623 | struct uv_fs_event_req_s { \ 624 | UV_REQ_FIELDS \ 625 | } req; \ 626 | HANDLE dir_handle; \ 627 | int req_pending; \ 628 | uv_fs_event_cb cb; \ 629 | WCHAR* filew; \ 630 | WCHAR* short_filew; \ 631 | WCHAR* dirw; \ 632 | char* buffer; 633 | 634 | #define UV_SIGNAL_PRIVATE_FIELDS \ 635 | RB_ENTRY(uv_signal_s) tree_entry; \ 636 | struct uv_req_s signal_req; \ 637 | unsigned long pending_signum; 638 | 639 | #ifndef F_OK 640 | #define F_OK 0 641 | #endif 642 | #ifndef R_OK 643 | #define R_OK 4 644 | #endif 645 | #ifndef W_OK 646 | #define W_OK 2 647 | #endif 648 | #ifndef X_OK 649 | #define X_OK 1 650 | #endif 651 | -------------------------------------------------------------------------------- /curl_multi/libuv/lib/libuv.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/libuv/lib/libuv.lib -------------------------------------------------------------------------------- /curl_multi/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/main.cpp -------------------------------------------------------------------------------- /curl_multi/scCookie.txt: -------------------------------------------------------------------------------- 1 | # Netscape HTTP Cookie File 2 | # https://curl.haxx.se/docs/http-cookies.html 3 | # This file was generated by libcurl! Edit at your own risk. 4 | 5 | blog.csdn.net FALSE / FALSE 1502152531 uuid caf2f79e-0ce1-439a-9b76-2987413f5110 6 | blog.csdn.net FALSE / FALSE 1502069731 avh 39396237 7 | .baidu.com TRUE / FALSE 3649550483 BAIDUID 842828FB93624C9C53771859247BC280:FG=1 8 | .baidu.com TRUE / FALSE 3649550483 BIDUPSID 842828FB93624C9C53771859247BC280 9 | .baidu.com TRUE / FALSE 3649550483 PSTM 1502066755 10 | www.baidu.com FALSE / FALSE 0 BDSVRTM 15 11 | www.baidu.com FALSE / FALSE 0 BD_HOME 0 12 | .baidu.com TRUE / FALSE 0 H_PS_PSSID 1449_21081_17001 13 | -------------------------------------------------------------------------------- /curl_multi/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/stdafx.cpp -------------------------------------------------------------------------------- /curl_multi/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/stdafx.h -------------------------------------------------------------------------------- /curl_multi/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KevinsBobo/curl_multi/c35cbdbb25cd6abbe34d6fc610e3f31d36b01443/curl_multi/targetver.h -------------------------------------------------------------------------------- /curl_multi/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "uv.h" 3 | #include 4 | #include 5 | #include "SkyChaserHttp.h" 6 | #include "curl.h" 7 | 8 | 9 | uv_loop_t *loop; 10 | CURLM *curl_handle; 11 | uv_timer_t timeout; 12 | 13 | typedef struct curl_context_s { 14 | uv_poll_t poll_handle; 15 | curl_socket_t sockfd; 16 | } curl_context_t; 17 | 18 | curl_context_t *create_curl_context(curl_socket_t sockfd) { 19 | curl_context_t *context; 20 | 21 | context = (curl_context_t*) malloc(sizeof *context); 22 | 23 | context->sockfd = sockfd; 24 | 25 | //使用socket描述符初始化handle 26 | int r = uv_poll_init_socket(loop, &context->poll_handle, sockfd); 27 | assert(r == 0); 28 | context->poll_handle.data = context; 29 | 30 | return context; 31 | } 32 | 33 | void curl_close_cb(uv_handle_t *handle) { 34 | curl_context_t *context = (curl_context_t*) handle->data; 35 | free(context); 36 | } 37 | 38 | void destroy_curl_context(curl_context_t *context) { 39 | //uv_close关闭所有的流 40 | uv_close((uv_handle_t*) &context->poll_handle, curl_close_cb); 41 | } 42 | 43 | 44 | void add_download(const char *url, int num) { 45 | char filename[50]; 46 | sprintf(filename, "%d.download", num); 47 | FILE *file; 48 | 49 | file = fopen(filename, "w"); 50 | if (file == NULL) { 51 | fprintf(stderr, "Error opening %s\n", filename); 52 | return; 53 | } 54 | 55 | CURL *handle = curl_easy_init(); 56 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, file); 57 | curl_easy_setopt(handle, CURLOPT_URL, url); 58 | //调用curl_multi_add_handle添加handle后,会回调start_timeout,然后调用 59 | curl_multi_add_handle(curl_handle, handle); 60 | fprintf(stderr, "Added download %s -> %s\n", url, filename); 61 | } 62 | 63 | //检测easy handle是否发送成功,成功则把easy handle移除出multi stack 64 | void check_multi_info(void) { 65 | char *done_url; 66 | CURLMsg *message; 67 | int pending; 68 | 69 | while ((message = curl_multi_info_read(curl_handle, &pending))) { 70 | switch (message->msg) { 71 | case CURLMSG_DONE: 72 | curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL, 73 | &done_url); 74 | printf("%s DONE\n", done_url); 75 | 76 | curl_multi_remove_handle(curl_handle, message->easy_handle); 77 | curl_easy_cleanup(message->easy_handle); 78 | break; 79 | 80 | default: 81 | fprintf(stderr, "CURLMSG default\n"); 82 | abort(); 83 | } 84 | } 85 | } 86 | 87 | void curl_perform(uv_poll_t *req, int status, int events) { 88 | //停止timer,回调函数将不会再被调用 89 | uv_timer_stop(&timeout); 90 | int running_handles; 91 | int flags = 0; 92 | if (status < 0) flags = CURL_CSELECT_ERR; 93 | if (!status && events & UV_READABLE) flags |= CURL_CSELECT_IN; 94 | if (!status && events & UV_WRITABLE) flags |= CURL_CSELECT_OUT; 95 | 96 | curl_context_t *context; 97 | 98 | context = (curl_context_t*)req; 99 | 100 | /*当事件管理器发现socket状态改变时通过curl_multi_socket_action(g->multi, fd, action, &g->still_running) 101 | 通知libcurl读写数据,然后再调用sock_cb通知事件管理器,如此反复。*/ 102 | curl_multi_socket_action(curl_handle, context->sockfd, flags, &running_handles); 103 | check_multi_info(); 104 | } 105 | 106 | void on_timeout(uv_timer_t *req) { 107 | int running_handles; 108 | //初始化请求并得到一个socketfd 109 | curl_multi_socket_action(curl_handle, CURL_SOCKET_TIMEOUT, 0, &running_handles); 110 | check_multi_info(); 111 | } 112 | 113 | void start_timeout(CURLM *multi, long timeout_ms, void *userp) { 114 | if (timeout_ms <= 0) 115 | timeout_ms = 1; /* 0 means directly call socket_action, but we'll do it in a bit */ 116 | //注册自己的定时回调函数uv_timer_start 117 | uv_timer_start(&timeout, on_timeout, timeout_ms, 0); 118 | } 119 | 120 | int handle_socket(CURL *easy, curl_socket_t s, int action, void *userp, void *socketp) { 121 | curl_context_t *curl_context; 122 | if (action == CURL_POLL_IN || action == CURL_POLL_OUT) { 123 | if (socketp) { 124 | curl_context = (curl_context_t*) socketp; 125 | } 126 | else { 127 | curl_context = create_curl_context(s); 128 | curl_multi_assign(curl_handle, s, (void *) curl_context); 129 | } 130 | } 131 | 132 | switch (action) { 133 | case CURL_POLL_IN: 134 | //开始polling文件描述符,一旦检测到读事件,则调用curl_perform函数,参数status设置为0 135 | uv_poll_start(&curl_context->poll_handle, UV_READABLE, curl_perform); 136 | break; 137 | case CURL_POLL_OUT: 138 | uv_poll_start(&curl_context->poll_handle, UV_WRITABLE, curl_perform); 139 | break; 140 | case CURL_POLL_REMOVE: 141 | if (socketp) { 142 | //停止polling文件描述符 143 | uv_poll_stop(&((curl_context_t*)socketp)->poll_handle); 144 | destroy_curl_context((curl_context_t*) socketp); 145 | curl_multi_assign(curl_handle, s, NULL); 146 | } 147 | break; 148 | default: 149 | abort(); 150 | } 151 | 152 | return 0; 153 | } 154 | 155 | int main(int argc, char **argv) { 156 | /*libuv 提供了一个默认的事件循环, 你可以通过 uv_default_loop 来获得该事件循环, 157 | 如果你的程序中只有一个事件循环, 你就应该使用 libuv 为我们提供的默认事件循环*/ 158 | loop = uv_default_loop(); 159 | 160 | if (argc <= 1) 161 | return 0; 162 | 163 | if (curl_global_init(CURL_GLOBAL_ALL)) { 164 | fprintf(stderr, "Could not init cURL\n"); 165 | return 1; 166 | } 167 | 168 | //初始化定时器 169 | uv_timer_init(loop, &timeout); 170 | 171 | curl_handle = curl_multi_init(); 172 | //调用handle_socket回调函数,传入新建的sockfd,根据传入的action状态添加到相应的事件管理器,如封装epoll的libev或libevent。 173 | curl_multi_setopt(curl_handle, CURLMOPT_SOCKETFUNCTION, handle_socket); 174 | /*当使用curl_multi_add_handle(g->multi, conn->easy)添加请求时会回调start_timeout,然后调用 175 | curl_multi_socket_action(curl_handle, CURL_SOCKET_TIMEOUT, 0, &running_handles)初始化请求并得到一个socket(fd)*/ 176 | curl_multi_setopt(curl_handle, CURLMOPT_TIMERFUNCTION, start_timeout); 177 | 178 | while (argc-- > 1) { 179 | //添加待处理的easy handle 180 | add_download(argv[argc], argc); 181 | } 182 | 183 | //事件循环由 uv_run 函数封装, 在使用libuv编程时, 该函数通常在最后才被调用. 184 | uv_run(loop, UV_RUN_DEFAULT); 185 | curl_multi_cleanup(curl_handle); 186 | 187 | getchar(); 188 | return 0; 189 | } -------------------------------------------------------------------------------- /curl_multi/use_curl_multi.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SkyChaserHttp.h" 3 | #include "libcurl/multi.h" 4 | #include "use_curl_multi.h" 5 | #include "time.h" 6 | 7 | // #define MAX_WAIT_MSECS 30*1000 /* Wait max. 30 seconds */ 8 | 9 | // static const char *urls[] = { 10 | // "http://www.microsoft.com", 11 | // "http://www.yahoo.com", 12 | // "http://www.wikipedia.org", 13 | // "http://slashdot.org" 14 | // }; 15 | 16 | // #define CNT 4 17 | 18 | static size_t cb(char *d, size_t n, size_t l, void *p) 19 | { 20 | /* take care of the data here, ignored in this example */ 21 | (void)d; 22 | (void)p; 23 | 24 | printf("%uld,%ud, %s\n" , GetCurrentThreadId() , n , d); 25 | return n*l; 26 | } 27 | 28 | static void init(CURLM *cm, int i) 29 | { 30 | CURL *eh = curl_easy_init(); 31 | curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, cb); 32 | curl_easy_setopt(eh, CURLOPT_HEADER, 0L); 33 | curl_easy_setopt(eh, CURLOPT_URL, urls[i]); 34 | curl_easy_setopt(eh, CURLOPT_PRIVATE, urls[i]); 35 | curl_easy_setopt(eh, CURLOPT_VERBOSE, 0L); 36 | curl_multi_add_handle(cm, eh); 37 | } 38 | 39 | int start_test(void) 40 | { 41 | CURLM *cm=NULL; 42 | CURL *eh=NULL; 43 | CURLMsg *msg=NULL; 44 | CURLcode return_code=CURLE_OK; 45 | int still_running=0, i=0, msgs_left=0; 46 | int http_status_code; 47 | const char *szUrl; 48 | 49 | curl_global_init(CURL_GLOBAL_ALL); 50 | 51 | cm = curl_multi_init(); 52 | 53 | for (i = 0; i < CNT; ++i) { 54 | init(cm, i); 55 | } 56 | 57 | curl_multi_perform(cm, &still_running); 58 | 59 | do { 60 | // printf("%uld\n" , GetCurrentThreadId()); 61 | int numfds=0; 62 | int res = curl_multi_wait(cm, NULL, 0, MAX_WAIT_MSECS, &numfds); 63 | if(res != CURLM_OK) { 64 | fprintf(stderr, "error: curl_multi_wait() returned %d\n", res); 65 | return EXIT_FAILURE; 66 | } 67 | /* 68 | if(!numfds) { 69 | fprintf(stderr, "error: curl_multi_wait() numfds=%d\n", numfds); 70 | return EXIT_FAILURE; 71 | } 72 | */ 73 | curl_multi_perform(cm, &still_running); 74 | 75 | } while(still_running); 76 | 77 | while ((msg = curl_multi_info_read(cm, &msgs_left))) { 78 | if (msg->msg == CURLMSG_DONE) { 79 | eh = msg->easy_handle; 80 | 81 | return_code = msg->data.result; 82 | if(return_code!=CURLE_OK) { 83 | fprintf(stderr, "CURL error code: %d\n", msg->data.result); 84 | continue; 85 | } 86 | 87 | // Get HTTP status code 88 | http_status_code=0; 89 | szUrl = NULL; 90 | 91 | curl_easy_getinfo(eh, CURLINFO_RESPONSE_CODE, &http_status_code); 92 | curl_easy_getinfo(eh, CURLINFO_PRIVATE, &szUrl); 93 | 94 | if(http_status_code==200) { 95 | printf("200 OK for %s\n", szUrl); 96 | } else { 97 | fprintf(stderr, "GET of %s returned http status code %d\n", szUrl, http_status_code); 98 | } 99 | 100 | curl_multi_remove_handle(cm, eh); 101 | curl_easy_cleanup(eh); 102 | } 103 | else { 104 | fprintf(stderr, "error: after curl_multi_info_read(), CURLMsg=%d\n", msg->msg); 105 | } 106 | } 107 | 108 | curl_multi_cleanup(cm); 109 | 110 | return EXIT_SUCCESS; 111 | } -------------------------------------------------------------------------------- /curl_multi/use_curl_multi.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #ifndef WIN32 4 | #include 5 | #endif 6 | 7 | #include "libcurl/multi.h" 8 | 9 | #define MAX_WAIT_MSECS 30*1000 /* Wait max. 30 seconds */ 10 | 11 | static const char *urls[] = { 12 | "http://www.microsoft.com", 13 | "http://www.yahoo.com", 14 | "http://www.baidu.com", 15 | "http://www.sogou.com", 16 | "http://www.soso.com" 17 | }; 18 | #define CNT 5 19 | 20 | static size_t cb(char *d , size_t n , size_t l , void *p); 21 | 22 | static void init(CURLM *cm , int i); 23 | 24 | int start_test(void); 25 | --------------------------------------------------------------------------------