├── LICENSE ├── README.md ├── 12306.txt ├── 12306Client_MFC.v11.suo ├── 12306Client_MFC ├── MainFrm.h ├── stdafx.h ├── LoginDlg.cpp ├── LoginDlg.h ├── MainFrm.cpp ├── MainView.cpp ├── MainView.h ├── OutputWnd.h ├── TBButton.cpp ├── resource.h ├── stdafx.cpp ├── targetver.h ├── OutputWnd.cpp ├── 12306Client_MFC.h ├── TBHeaderCtrl.cpp ├── 12306Client_MFC.aps ├── 12306Client_MFC.cpp ├── 12306Client_MFC.rc ├── 12306Client_MFCDoc.cpp ├── 12306Client_MFCDoc.h ├── 12306Client_MFCView.h ├── lib │ ├── debug │ │ ├── libcurl.lib │ │ └── json_vc71_libmtd.lib │ └── release │ │ ├── libcurl.lib │ │ └── json_vc71_libmt.lib ├── 12306Client_MFCView.cpp ├── res │ ├── 12306Client_MFC.ico │ ├── 12306Client_MFCDoc.ico │ └── My12306Client_MFC.rc2 ├── 12306Client_MFC.vcxproj.user ├── Operate.h ├── include │ ├── json │ │ ├── json.h │ │ ├── autolink.h │ │ ├── forwards.h │ │ ├── features.h │ │ ├── config.h │ │ ├── writer.h │ │ └── reader.h │ └── curl │ │ ├── stdcheaders.h │ │ ├── curlver.h │ │ ├── mprintf.h │ │ ├── easy.h │ │ ├── curlbuild.h.in │ │ ├── curlbuild.h.cmake │ │ ├── curlrules.h │ │ ├── multi.h │ │ ├── curlbuild.h │ │ └── typecheck-gcc.h ├── TBColorButton.h ├── TBButton.h ├── TBHeaderCtrl.h ├── UrlWrapper.h ├── Operate.cpp ├── TBColorButton.cpp ├── ReadMe.txt ├── 12306Client_MFC.vcxproj.filters ├── TBListCtrl.h ├── UrlWrapper.cpp ├── 12306Client_MFC.vcxproj └── TBListCtrl.cpp ├── Release └── 12306Client_MFC.exe ├── .gitignore └── 12306Client_MFC.sln /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 12306 2 | ===== 3 | 4 | 12306客户端(MFC版本) 5 | -------------------------------------------------------------------------------- /12306.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306.txt -------------------------------------------------------------------------------- /12306Client_MFC.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC.v11.suo -------------------------------------------------------------------------------- /12306Client_MFC/MainFrm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/MainFrm.h -------------------------------------------------------------------------------- /12306Client_MFC/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/stdafx.h -------------------------------------------------------------------------------- /12306Client_MFC/LoginDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/LoginDlg.cpp -------------------------------------------------------------------------------- /12306Client_MFC/LoginDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/LoginDlg.h -------------------------------------------------------------------------------- /12306Client_MFC/MainFrm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/MainFrm.cpp -------------------------------------------------------------------------------- /12306Client_MFC/MainView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/MainView.cpp -------------------------------------------------------------------------------- /12306Client_MFC/MainView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/MainView.h -------------------------------------------------------------------------------- /12306Client_MFC/OutputWnd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/OutputWnd.h -------------------------------------------------------------------------------- /12306Client_MFC/TBButton.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/TBButton.cpp -------------------------------------------------------------------------------- /12306Client_MFC/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/resource.h -------------------------------------------------------------------------------- /12306Client_MFC/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/stdafx.cpp -------------------------------------------------------------------------------- /12306Client_MFC/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/targetver.h -------------------------------------------------------------------------------- /Release/12306Client_MFC.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/Release/12306Client_MFC.exe -------------------------------------------------------------------------------- /12306Client_MFC/OutputWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/OutputWnd.cpp -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFC.h -------------------------------------------------------------------------------- /12306Client_MFC/TBHeaderCtrl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/TBHeaderCtrl.cpp -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFC.aps -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFC.cpp -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFC.rc -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFCDoc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFCDoc.cpp -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFCDoc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFCDoc.h -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFCView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFCView.h -------------------------------------------------------------------------------- /12306Client_MFC/lib/debug/libcurl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/lib/debug/libcurl.lib -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFCView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/12306Client_MFCView.cpp -------------------------------------------------------------------------------- /12306Client_MFC/lib/release/libcurl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/lib/release/libcurl.lib -------------------------------------------------------------------------------- /12306Client_MFC/res/12306Client_MFC.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/res/12306Client_MFC.ico -------------------------------------------------------------------------------- /12306Client_MFC/res/12306Client_MFCDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/res/12306Client_MFCDoc.ico -------------------------------------------------------------------------------- /12306Client_MFC/res/My12306Client_MFC.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/res/My12306Client_MFC.rc2 -------------------------------------------------------------------------------- /12306Client_MFC/lib/debug/json_vc71_libmtd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/lib/debug/json_vc71_libmtd.lib -------------------------------------------------------------------------------- /12306Client_MFC/lib/release/json_vc71_libmt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lniwn/12306/HEAD/12306Client_MFC/lib/release/json_vc71_libmt.lib -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /12306Client_MFC/Operate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int utf8ToUnicode(const char* src, int src_len, wchar_t* dst); 4 | 5 | int unicodeToUtf8(const wchar_t* src, int src_len, char* dst); 6 | 7 | HGLOBAL CreateStreamFromMemory(void* src, size_t len, IStream** ppStream); -------------------------------------------------------------------------------- /12306Client_MFC/include/json/json.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_JSON_H_INCLUDED 2 | # define JSON_JSON_H_INCLUDED 3 | 4 | # include "autolink.h" 5 | # include "value.h" 6 | # include "reader.h" 7 | # include "writer.h" 8 | # include "features.h" 9 | 10 | #endif // JSON_JSON_H_INCLUDED 11 | -------------------------------------------------------------------------------- /12306Client_MFC/TBColorButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CTBColorButton 5 | 6 | class CTBColorButton : public CMFCColorButton 7 | { 8 | DECLARE_DYNAMIC(CTBColorButton) 9 | 10 | public: 11 | CTBColorButton(DWORD dwItem, DWORD dwSubItem); 12 | virtual ~CTBColorButton(); 13 | 14 | protected: 15 | DECLARE_MESSAGE_MAP() 16 | afx_msg void OnBnClicked(); 17 | afx_msg LRESULT OnMove(WPARAM wParam, LPARAM lParam); 18 | 19 | private: 20 | DWORD m_dwItem; 21 | DWORD m_dwSubItem; 22 | }; 23 | 24 | 25 | -------------------------------------------------------------------------------- /12306Client_MFC/TBButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef UM_MOVE_COMPONENT 4 | #define UM_MOVE_COMPONENT WM_USER+101 5 | #endif 6 | // CTBButton 7 | 8 | class CTBButton : public CButton 9 | { 10 | DECLARE_DYNAMIC(CTBButton) 11 | 12 | public: 13 | CTBButton(DWORD dwItem, DWORD dwSubItem); 14 | virtual ~CTBButton(); 15 | 16 | protected: 17 | DECLARE_MESSAGE_MAP() 18 | afx_msg void OnBnClicked(); 19 | afx_msg LRESULT OnMove(WPARAM wParam, LPARAM lParam); 20 | 21 | private: 22 | DWORD m_dwItem; 23 | DWORD m_dwSubItem; 24 | }; 25 | 26 | 27 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/autolink.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_AUTOLINK_H_INCLUDED 2 | # define JSON_AUTOLINK_H_INCLUDED 3 | 4 | # include "config.h" 5 | 6 | # ifdef JSON_IN_CPPTL 7 | # include 8 | # endif 9 | 10 | # if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL) 11 | # define CPPTL_AUTOLINK_NAME "json" 12 | # undef CPPTL_AUTOLINK_DLL 13 | # ifdef JSON_DLL 14 | # define CPPTL_AUTOLINK_DLL 15 | # endif 16 | # include "autolink.h" 17 | # endif 18 | 19 | #endif // JSON_AUTOLINK_H_INCLUDED 20 | -------------------------------------------------------------------------------- /12306Client_MFC/TBHeaderCtrl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CHeaderCtrlCl 5 | 6 | class CTBHeaderCtrl : public CHeaderCtrl 7 | { 8 | DECLARE_DYNAMIC(CTBHeaderCtrl) 9 | 10 | public: 11 | CTBHeaderCtrl(); 12 | virtual ~CTBHeaderCtrl(); 13 | private: 14 | CListCtrl* m_pListCtrl; 15 | 16 | protected: 17 | DECLARE_MESSAGE_MAP() 18 | public: 19 | 20 | afx_msg void OnPaint(); 21 | 22 | private: 23 | friend class CTBListCtrl; 24 | int m_R; 25 | int m_G; 26 | int m_B; 27 | int m_Gradient; 28 | float m_Height; 29 | int m_fontHeight; 30 | int m_fontWith; 31 | COLORREF m_color; 32 | LRESULT OnLayout( WPARAM wParam, LPARAM lParam ); 33 | void SetListCtrl(CListCtrl*); 34 | void DrawHeader(CDC* pDC = NULL); 35 | virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult); 36 | }; 37 | 38 | 39 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/forwards.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_FORWARDS_H_INCLUDED 2 | # define JSON_FORWARDS_H_INCLUDED 3 | 4 | # include "config.h" 5 | 6 | namespace Json { 7 | 8 | // writer.h 9 | class FastWriter; 10 | class StyledWriter; 11 | 12 | // reader.h 13 | class Reader; 14 | 15 | // features.h 16 | class Features; 17 | 18 | // value.h 19 | typedef int Int; 20 | typedef unsigned int UInt; 21 | class StaticString; 22 | class Path; 23 | class PathArgument; 24 | class Value; 25 | class ValueIteratorBase; 26 | class ValueIterator; 27 | class ValueConstIterator; 28 | #ifdef JSON_VALUE_USE_INTERNAL_MAP 29 | class ValueAllocator; 30 | class ValueMapAllocator; 31 | class ValueInternalLink; 32 | class ValueInternalArray; 33 | class ValueInternalMap; 34 | #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 35 | 36 | } // namespace Json 37 | 38 | 39 | #endif // JSON_FORWARDS_H_INCLUDED 40 | -------------------------------------------------------------------------------- /12306Client_MFC/UrlWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | extern "C" 5 | { 6 | #include 7 | } 8 | class CUrlWrapper 9 | { 10 | public: 11 | CUrlWrapper(void); 12 | ~CUrlWrapper(void); 13 | 14 | bool Init(); 15 | bool doHttpPost( const char* url, const char* data, long timeout = 10); 16 | bool doHttpGet( const char* url, const char* data, long timeout = 10); 17 | bool doHttpsGet(const char* url, long timeout = 10); 18 | bool doHttpsPost(const char* url, const char* post_data, long timeout = 10); 19 | void resetOpt(); 20 | void getRandom(char* code, size_t sizeOfBuffer); 21 | size_t getResponseData(void* data, size_t len); 22 | size_t getResponseLength(); 23 | private: 24 | CURL* m_pCurlObj; 25 | curl_slist* createHeader(curl_slist *headers); 26 | int process(void* data, size_t size, size_t nmemb); 27 | static size_t processFunc( void* ptr, size_t size, size_t nmemb, void *usrptr ); 28 | std::vector m_response; 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /12306Client_MFC.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "12306Client_MFC", "12306Client_MFC\12306Client_MFC.vcxproj", "{6855A594-5AD9-4AE7-8D67-7AB611ABD19F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {6855A594-5AD9-4AE7-8D67-7AB611ABD19F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {6855A594-5AD9-4AE7-8D67-7AB611ABD19F}.Debug|Win32.Build.0 = Debug|Win32 14 | {6855A594-5AD9-4AE7-8D67-7AB611ABD19F}.Release|Win32.ActiveCfg = Release|Win32 15 | {6855A594-5AD9-4AE7-8D67-7AB611ABD19F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /12306Client_MFC/Operate.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Operate.h" 3 | 4 | int utf8ToUnicode(const char* src, int src_len, wchar_t* dst) 5 | { 6 | int wcs_len = ::MultiByteToWideChar(CP_UTF8, 0, src, src_len, NULL, 0); 7 | if(0 == wcs_len) return 0; 8 | return ::MultiByteToWideChar(CP_UTF8, 0, src, src_len, dst, wcs_len); 9 | } 10 | 11 | int unicodeToUtf8(const wchar_t* src, int src_len, char* dst) 12 | { 13 | int utf8_len = ::WideCharToMultiByte(CP_UTF8, 0, src, src_len, NULL, 0, nullptr, nullptr); 14 | if(0 == utf8_len) return 0; 15 | return ::WideCharToMultiByte(CP_UTF8, 0, src, src_len, dst, utf8_len, nullptr, nullptr); 16 | } 17 | 18 | HGLOBAL CreateStreamFromMemory(void* src, size_t len, IStream** ppStream) 19 | { 20 | HGLOBAL hGlobal = ::GlobalAlloc(GMEM_MOVEABLE, len); 21 | ASSERT(hGlobal); 22 | LPVOID pData = ::GlobalLock(hGlobal); 23 | ASSERT(pData); 24 | CopyMemory(pData, src, len); 25 | VERIFY(SUCCEEDED(::CreateStreamOnHGlobal(hGlobal, TRUE, ppStream))); 26 | ::GlobalUnlock(hGlobal); 27 | return hGlobal; 28 | } -------------------------------------------------------------------------------- /12306Client_MFC/TBColorButton.cpp: -------------------------------------------------------------------------------- 1 | // TBColorButton.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TBColorButton.h" 6 | 7 | 8 | #ifndef UM_MOVE_COMPONENT 9 | #define UM_MOVE_COMPONENT WM_USER+101 10 | #endif 11 | 12 | // CTBColorButton 13 | 14 | IMPLEMENT_DYNAMIC(CTBColorButton, CMFCColorButton) 15 | 16 | CTBColorButton::CTBColorButton(DWORD dwItem, DWORD dwSubItem) 17 | { 18 | m_dwItem = dwItem; 19 | m_dwSubItem = dwSubItem; 20 | } 21 | 22 | CTBColorButton::~CTBColorButton() 23 | { 24 | } 25 | 26 | 27 | BEGIN_MESSAGE_MAP(CTBColorButton, CMFCColorButton) 28 | ON_CONTROL_REFLECT(BN_CLICKED, &CTBColorButton::OnBnClicked) 29 | ON_MESSAGE(UM_MOVE_COMPONENT, &CTBColorButton::OnMove) 30 | END_MESSAGE_MAP() 31 | 32 | 33 | 34 | // CTBColorButton message handlers 35 | 36 | void CTBColorButton::OnBnClicked() 37 | { 38 | ::SendMessage(GetParent()->m_hWnd, BN_CLICKED, m_dwItem, m_dwSubItem); 39 | } 40 | 41 | 42 | LRESULT CTBColorButton::OnMove(WPARAM wParam, LPARAM lParam) 43 | { 44 | m_dwItem = wParam; 45 | m_dwSubItem = lParam; 46 | return 1; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/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 http://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 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/features.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTL_JSON_FEATURES_H_INCLUDED 2 | # define CPPTL_JSON_FEATURES_H_INCLUDED 3 | 4 | # include "forwards.h" 5 | 6 | namespace Json { 7 | 8 | /** \brief Configuration passed to reader and writer. 9 | * This configuration object can be used to force the Reader or Writer 10 | * to behave in a standard conforming way. 11 | */ 12 | class JSON_API Features 13 | { 14 | public: 15 | /** \brief A configuration that allows all features and assumes all strings are UTF-8. 16 | * - C & C++ comments are allowed 17 | * - Root object can be any JSON value 18 | * - Assumes Value strings are encoded in UTF-8 19 | */ 20 | static Features all(); 21 | 22 | /** \brief A configuration that is strictly compatible with the JSON specification. 23 | * - Comments are forbidden. 24 | * - Root object must be either an array or an object value. 25 | * - Assumes Value strings are encoded in UTF-8 26 | */ 27 | static Features strictMode(); 28 | 29 | /** \brief Initialize the configuration like JsonConfig::allFeatures; 30 | */ 31 | Features(); 32 | 33 | /// \c true if comments are allowed. Default: \c true. 34 | bool allowComments_; 35 | 36 | /// \c true if root must be either an array or an object value. Default: \c false. 37 | bool strictRoot_; 38 | }; 39 | 40 | } // namespace Json 41 | 42 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED 43 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/config.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_CONFIG_H_INCLUDED 2 | # define JSON_CONFIG_H_INCLUDED 3 | 4 | /// If defined, indicates that json library is embedded in CppTL library. 5 | //# define JSON_IN_CPPTL 1 6 | 7 | /// If defined, indicates that json may leverage CppTL library 8 | //# define JSON_USE_CPPTL 1 9 | /// If defined, indicates that cpptl vector based map should be used instead of std::map 10 | /// as Value container. 11 | //# define JSON_USE_CPPTL_SMALLMAP 1 12 | /// If defined, indicates that Json specific container should be used 13 | /// (hash table & simple deque container with customizable allocator). 14 | /// THIS FEATURE IS STILL EXPERIMENTAL! 15 | //# define JSON_VALUE_USE_INTERNAL_MAP 1 16 | /// Force usage of standard new/malloc based allocator instead of memory pool based allocator. 17 | /// The memory pools allocator used optimization (initializing Value and ValueInternalLink 18 | /// as if it was a POD) that may cause some validation tool to report errors. 19 | /// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. 20 | //# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 21 | 22 | /// If defined, indicates that Json use exception to report invalid type manipulation 23 | /// instead of C assert macro. 24 | # define JSON_USE_EXCEPTION 1 25 | 26 | # ifdef JSON_IN_CPPTL 27 | # include 28 | # ifndef JSON_USE_CPPTL 29 | # define JSON_USE_CPPTL 1 30 | # endif 31 | # endif 32 | 33 | # ifdef JSON_IN_CPPTL 34 | # define JSON_API CPPTL_API 35 | # elif defined(JSON_DLL_BUILD) 36 | # define JSON_API __declspec(dllexport) 37 | # elif defined(JSON_DLL) 38 | # define JSON_API __declspec(dllimport) 39 | # else 40 | # define JSON_API 41 | # endif 42 | 43 | #endif // JSON_CONFIG_H_INCLUDED 44 | -------------------------------------------------------------------------------- /12306Client_MFC/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | MICROSOFT 基础类库 : 12306Client_MFC 项目概述 3 | =============================================================================== 4 | 5 | 应用程序向导已为您创建了此 12306Client_MFC 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 6 | 7 | 本文件概要介绍组成 12306Client_MFC 应用程序的每个文件的内容。 8 | 9 | 12306Client_MFC.vcxproj 10 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 11 | 12 | 12306Client_MFC.vcxproj.filters 13 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 14 | 15 | 12306Client_MFC.h 16 | 这是应用程序的主头文件。 17 | 其中包括其他项目特定的标头(包括 Resource.h),并声明 CMy12306Client_MFCApp 应用程序类。 18 | 19 | 12306Client_MFC.cpp 20 | 这是包含应用程序类 CMy12306Client_MFCApp 的主应用程序源文件。 21 | 22 | 12306Client_MFC.rc 23 | 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 24 | 25 | res\12306Client_MFC.ico 26 | 这是用作应用程序图标的图标文件。此图标包括在主资源文件 12306Client_MFC.rc 中。 27 | 28 | res\My12306Client_MFC.rc2 29 | 此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | 33 | 对于主框架窗口: 34 | 该项目包含一个标准的 MFC 接口。 35 | 36 | MainFrm.h, MainFrm.cpp 37 | 这些文件中包含框架类 CMainFrame,该类派生自 38 | CFrameWnd 并控制所有 SDI 框架功能。 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | 42 | 应用程序向导创建一种文档类型和一个视图: 43 | 44 | 12306Client_MFCDoc.h、12306Client_MFCDoc.cpp - 文档 45 | 这些文件包含 CMy12306Client_MFCDoc 类。编辑这些文件以添加特殊文档数据并实现文件保存和加载(通过 CMy12306Client_MFCDoc::Serialize)。 46 | 47 | 12306Client_MFCView.h、12306Client_MFCView.cpp - 文档视图 48 | 这些文件包含 CMy12306Client_MFCView 类。 49 | CMy12306Client_MFCView 对象用于查看 CMy12306Client_MFCDoc 对象。 50 | 51 | 52 | 53 | 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 其他功能: 57 | 58 | ActiveX 控件 59 | 该应用程序包含对使用 ActiveX 控件的支持。 60 | 61 | Windows 套接字 62 | 应用程序包含对通过 TCP/IP 网络建立通信的支持。 63 | 64 | ///////////////////////////////////////////////////////////////////////////// 65 | 66 | 其他标准文件: 67 | 68 | StdAfx.h, StdAfx.cpp 69 | 这些文件用于生成名为 12306Client_MFC.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 70 | 71 | Resource.h 72 | 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 73 | 74 | 12306Client_MFC.manifest 75 | Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 76 | ///////////////////////////////////////////////////////////////////////////// 77 | 78 | 其他注释: 79 | 80 | 应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 81 | 82 | 如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 83 | 有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 84 | 85 | ///////////////////////////////////////////////////////////////////////////// 86 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLVER_H 2 | #define __CURL_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, 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 http://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 - 2013 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.34.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 34 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 | #define LIBCURL_VERSION_NUM 0x072200 57 | 58 | /* 59 | * This is the date and time when the full source package was created. The 60 | * timestamp is not stored in git, as the timestamp is properly set in the 61 | * tarballs by the maketgz script. 62 | * 63 | * The format of the date should follow this template: 64 | * 65 | * "Mon Feb 12 11:35:33 UTC 2007" 66 | */ 67 | #define LIBCURL_TIMESTAMP "Tue Dec 17 07:51:08 UTC 2013" 68 | 69 | #endif /* __CURL_CURLVER_H */ 70 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MPRINTF_H 2 | #define __CURL_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, 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 http://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 | 28 | #include "curl.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | CURL_EXTERN int curl_mprintf(const char *format, ...); 35 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 36 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 37 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 38 | const char *format, ...); 39 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 40 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 42 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 43 | const char *format, va_list args); 44 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 45 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 46 | 47 | #ifdef _MPRINTF_REPLACE 48 | # undef printf 49 | # undef fprintf 50 | # undef sprintf 51 | # undef vsprintf 52 | # undef snprintf 53 | # undef vprintf 54 | # undef vfprintf 55 | # undef vsnprintf 56 | # undef aprintf 57 | # undef vaprintf 58 | # define printf curl_mprintf 59 | # define fprintf curl_mfprintf 60 | #ifdef CURLDEBUG 61 | /* When built with CURLDEBUG we define away the sprintf functions since we 62 | don't want internal code to be using them */ 63 | # define sprintf sprintf_was_used 64 | # define vsprintf vsprintf_was_used 65 | #else 66 | # define sprintf curl_msprintf 67 | # define vsprintf curl_mvsprintf 68 | #endif 69 | # define snprintf curl_msnprintf 70 | # define vprintf curl_mvprintf 71 | # define vfprintf curl_mvfprintf 72 | # define vsnprintf curl_mvsnprintf 73 | # define aprintf curl_maprintf 74 | # define vaprintf curl_mvaprintf 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __CURL_MPRINTF_H */ 82 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/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 http://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 | -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.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;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 | 头文件 63 | 64 | 65 | 头文件 66 | 67 | 68 | 69 | 70 | 源文件 71 | 72 | 73 | 源文件 74 | 75 | 76 | 源文件 77 | 78 | 79 | 源文件 80 | 81 | 82 | 源文件 83 | 84 | 85 | 源文件 86 | 87 | 88 | 源文件 89 | 90 | 91 | 源文件 92 | 93 | 94 | 源文件 95 | 96 | 97 | 源文件 98 | 99 | 100 | 源文件 101 | 102 | 103 | 源文件 104 | 105 | 106 | 源文件 107 | 108 | 109 | 110 | 111 | 资源文件 112 | 113 | 114 | 115 | 116 | 资源文件 117 | 118 | 119 | 120 | 121 | 资源文件 122 | 123 | 124 | 资源文件 125 | 126 | 127 | -------------------------------------------------------------------------------- /12306Client_MFC/TBListCtrl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "TBButton.h" 6 | 7 | using std::map; 8 | using std::list; 9 | using std::vector; 10 | 11 | // move component, WPARAM: row number, LPARAM: col number 12 | //#define UM_MOVE_COMPONENT WM_USER+101 13 | 14 | #include "TBHeaderCtrl.h" 15 | 16 | 17 | //#define DEFAULT_TITLE_BK_COLOR RGB(0, 0, 0) 18 | //#define DEFAULT_TITLE_TEXT_COLOR RGB(255, 0, 0) 19 | #define DEFAULT_NORMAL_BK_COLOR RGB(255, 255, 255) 20 | #define DEFAULT_NORMAL_TEXT_COLOR RGB(0, 0, 0) 21 | 22 | typedef struct tagSUBITEM_INFO 23 | { 24 | int iSubItem; 25 | COLORREF clrTextColor; 26 | COLORREF clrBkColor; 27 | CString strNormal; // item text 28 | CButton* pBtn; 29 | }SUBITEM_INFO, *PSUBITEM_INFO; 30 | 31 | typedef struct tagITEM_INFO 32 | { 33 | //DWORD dwFlags; // LISTITEM_TITLE 34 | //CString strBold; 35 | //CString strNormal; 36 | //COLORREF clrBoldColor; 37 | COLORREF clrNormalColor; 38 | COLORREF clrBkColor; 39 | bool bSelected; 40 | list listSubItem; 41 | }ITEM_INFO, *PITEM_INFO; 42 | 43 | // CTBListCtrl 44 | 45 | class CTBListCtrl : public CListCtrl 46 | { 47 | DECLARE_DYNAMIC(CTBListCtrl) 48 | typedef map ItemMap; 49 | public: 50 | CTBListCtrl(); 51 | virtual ~CTBListCtrl(); 52 | 53 | // Method 54 | public: 55 | virtual BOOL DeleteAllItems(); 56 | virtual BOOL DeleteItem(_In_ int nItem); 57 | virtual BOOL DeleteColumn(_In_ int nCol); 58 | BOOL SetItemText(_In_ int nItem, _In_ int nSubItem, _In_z_ LPCTSTR lpszText, COLORREF clrTextColor = DEFAULT_NORMAL_TEXT_COLOR); 59 | BOOL SetItemTextColor(int iItem, int iSubItem, COLORREF clrColor); 60 | BOOL SetItemBkColor(int iItem, COLORREF clrBkColor); 61 | void SetRowHeight(int iItemHeight = 0x20); 62 | void InvalidAndUpdateWindow(); 63 | void InvalidAndUpdateItem(int iItem); 64 | int InsertItem(int iItem, LPCTSTR lpszItem, COLORREF clrBkColor = DEFAULT_NORMAL_BK_COLOR, 65 | COLORREF clrTextColor = DEFAULT_NORMAL_TEXT_COLOR); 66 | int InsertItem(int iItem, PITEM_INFO pItemInfo); 67 | BOOL SetItemButton(int iItem, int iSubItem, CButton* pBtn, int nID, DWORD dwStyle = 0, 68 | LPCTSTR lpszCaption = _T("")); 69 | CButton* GetItemButton(int iItem, int iSubItem); 70 | void SetLineColor(COLORREF clrLineColor); 71 | void SetSelectedRowColor(COLORREF clrRow); 72 | BOOL InitListCtrl(); 73 | void SetFontWidthHeight(DWORD dwWidth, DWORD dwHeight); 74 | void UpdateComponentPos(BOOL bRepaint = TRUE); 75 | BOOL GetCheck(int iItem) const; 76 | const std::vector& GetSelectedItems(); 77 | BOOL SetCheck(_In_ int nItem, _In_ BOOL fCheck = TRUE); 78 | BOOL MoveItem(int iItemFrom, int iItemTo); 79 | DWORD SetExtendedStyle(DWORD dwNewStyle); 80 | CString GetItemText(_In_ int nItem, _In_ int nSubItem); 81 | void SetHeaderHeightRatio(float fRatio); 82 | void SetHeaderBkColor(int R, int G, int B, int iGradient=1); 83 | void SetHeaderBkColor(COLORREF clrBk, int iGradient=1); 84 | void SetHeaderFontColor(COLORREF clrFont); 85 | void SetHeaderFontWithHeight(int iWidth, int iHeight); 86 | BOOL IsItemVisible(int iIndex); 87 | 88 | private: 89 | DWORD m_dwRowHeight; 90 | COLORREF m_clrLineColor; 91 | COLORREF m_clrSelectedRowColor; 92 | ItemMap m_mapItemInfo; 93 | DWORD m_dwFontWidth, m_dwFontHeight; 94 | static HHOOK m_hHook; 95 | static CWnd* m_pWnd; 96 | DWORD m_dwExStyle; 97 | vector m_vecSelectedItem; 98 | 99 | void GetFirstItemRect(int iItem, LPRECT pRect); 100 | void DrawNormalItem(LPDRAWITEMSTRUCT lpDrawItem); 101 | COLORREF GetItemTextColor(int iItem, int iSubItem); 102 | COLORREF GetItemBkColor(int iItem); 103 | void ClearMapInfo(); 104 | //void DeleteSelectedItem(int); 105 | 106 | static LRESULT CALLBACK CBTProc(int code,WPARAM wParam,LPARAM lParam); 107 | CTBHeaderCtrl m_headerCtrl; 108 | 109 | 110 | protected: 111 | virtual void PreSubclassWindow(); 112 | virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/); 113 | 114 | DECLARE_MESSAGE_MAP() 115 | public: 116 | //virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 117 | //afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); 118 | afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct ); 119 | afx_msg void OnDestroy(); 120 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 121 | //afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 122 | //afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 123 | afx_msg BOOL OnLvnEndScroll( NMHDR * pNotifyStruct, LRESULT* result); 124 | afx_msg BOOL OnNMClick( NMHDR * pNotifyStruct, LRESULT* result); 125 | //afx_msg void OnNMCustomDraw( NMHDR * pNotifyStruct, LRESULT* result); 126 | afx_msg void OnPaint(); 127 | 128 | // wParam: item 129 | // lParam: subItem 130 | afx_msg LRESULT OnBnClickedCallBack(WPARAM wParam, LPARAM lParam); 131 | 132 | }; 133 | 134 | 135 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_WRITER_H_INCLUDED 2 | # define JSON_WRITER_H_INCLUDED 3 | 4 | # include "value.h" 5 | # include 6 | # include 7 | # include 8 | 9 | namespace Json { 10 | 11 | class Value; 12 | 13 | /** \brief Abstract class for writers. 14 | */ 15 | class JSON_API Writer 16 | { 17 | public: 18 | virtual ~Writer(); 19 | 20 | virtual std::string write( const Value &root ) = 0; 21 | }; 22 | 23 | /** \brief Outputs a Value in JSON format without formatting (not human friendly). 24 | * 25 | * The JSON document is written in a single line. It is not intended for 'human' consumption, 26 | * but may be usefull to support feature such as RPC where bandwith is limited. 27 | * \sa Reader, Value 28 | */ 29 | class JSON_API FastWriter : public Writer 30 | { 31 | public: 32 | FastWriter(); 33 | virtual ~FastWriter(){} 34 | 35 | void enableYAMLCompatibility(); 36 | 37 | public: // overridden from Writer 38 | virtual std::string write( const Value &root ); 39 | 40 | private: 41 | void writeValue( const Value &value ); 42 | 43 | std::string document_; 44 | bool yamlCompatiblityEnabled_; 45 | }; 46 | 47 | /** \brief Writes a Value in JSON format in a human friendly way. 48 | * 49 | * The rules for line break and indent are as follow: 50 | * - Object value: 51 | * - if empty then print {} without indent and line break 52 | * - if not empty the print '{', line break & indent, print one value per line 53 | * and then unindent and line break and print '}'. 54 | * - Array value: 55 | * - if empty then print [] without indent and line break 56 | * - if the array contains no object value, empty array or some other value types, 57 | * and all the values fit on one lines, then print the array on a single line. 58 | * - otherwise, it the values do not fit on one line, or the array contains 59 | * object or non empty array, then print one value per line. 60 | * 61 | * If the Value have comments then they are outputed according to their #CommentPlacement. 62 | * 63 | * \sa Reader, Value, Value::setComment() 64 | */ 65 | class JSON_API StyledWriter: public Writer 66 | { 67 | public: 68 | StyledWriter(); 69 | virtual ~StyledWriter(){} 70 | 71 | public: // overridden from Writer 72 | /** \brief Serialize a Value in JSON format. 73 | * \param root Value to serialize. 74 | * \return String containing the JSON document that represents the root value. 75 | */ 76 | virtual std::string write( const Value &root ); 77 | 78 | private: 79 | void writeValue( const Value &value ); 80 | void writeArrayValue( const Value &value ); 81 | bool isMultineArray( const Value &value ); 82 | void pushValue( const std::string &value ); 83 | void writeIndent(); 84 | void writeWithIndent( const std::string &value ); 85 | void indent(); 86 | void unindent(); 87 | void writeCommentBeforeValue( const Value &root ); 88 | void writeCommentAfterValueOnSameLine( const Value &root ); 89 | bool hasCommentForValue( const Value &value ); 90 | static std::string normalizeEOL( const std::string &text ); 91 | 92 | typedef std::vector ChildValues; 93 | 94 | ChildValues childValues_; 95 | std::string document_; 96 | std::string indentString_; 97 | int rightMargin_; 98 | int indentSize_; 99 | bool addChildValues_; 100 | }; 101 | 102 | /** \brief Writes a Value in JSON format in a human friendly way, 103 | to a stream rather than to a string. 104 | * 105 | * The rules for line break and indent are as follow: 106 | * - Object value: 107 | * - if empty then print {} without indent and line break 108 | * - if not empty the print '{', line break & indent, print one value per line 109 | * and then unindent and line break and print '}'. 110 | * - Array value: 111 | * - if empty then print [] without indent and line break 112 | * - if the array contains no object value, empty array or some other value types, 113 | * and all the values fit on one lines, then print the array on a single line. 114 | * - otherwise, it the values do not fit on one line, or the array contains 115 | * object or non empty array, then print one value per line. 116 | * 117 | * If the Value have comments then they are outputed according to their #CommentPlacement. 118 | * 119 | * \param indentation Each level will be indented by this amount extra. 120 | * \sa Reader, Value, Value::setComment() 121 | */ 122 | class JSON_API StyledStreamWriter 123 | { 124 | public: 125 | StyledStreamWriter( std::string indentation="\t" ); 126 | ~StyledStreamWriter(){} 127 | 128 | public: 129 | /** \brief Serialize a Value in JSON format. 130 | * \param out Stream to write to. (Can be ostringstream, e.g.) 131 | * \param root Value to serialize. 132 | * \note There is no point in deriving from Writer, since write() should not return a value. 133 | */ 134 | void write( std::ostream &out, const Value &root ); 135 | 136 | private: 137 | void writeValue( const Value &value ); 138 | void writeArrayValue( const Value &value ); 139 | bool isMultineArray( const Value &value ); 140 | void pushValue( const std::string &value ); 141 | void writeIndent(); 142 | void writeWithIndent( const std::string &value ); 143 | void indent(); 144 | void unindent(); 145 | void writeCommentBeforeValue( const Value &root ); 146 | void writeCommentAfterValueOnSameLine( const Value &root ); 147 | bool hasCommentForValue( const Value &value ); 148 | static std::string normalizeEOL( const std::string &text ); 149 | 150 | typedef std::vector ChildValues; 151 | 152 | ChildValues childValues_; 153 | std::ostream* document_; 154 | std::string indentString_; 155 | int rightMargin_; 156 | std::string indentation_; 157 | bool addChildValues_; 158 | }; 159 | 160 | std::string JSON_API valueToString( Int value ); 161 | std::string JSON_API valueToString( UInt value ); 162 | std::string JSON_API valueToString( double value ); 163 | std::string JSON_API valueToString( bool value ); 164 | std::string JSON_API valueToQuotedString( const char *value ); 165 | 166 | /// \brief Output using the StyledStreamWriter. 167 | /// \see Json::operator>>() 168 | std::ostream& operator<<( std::ostream&, const Value &root ); 169 | 170 | } // namespace Json 171 | 172 | 173 | 174 | #endif // JSON_WRITER_H_INCLUDED 175 | -------------------------------------------------------------------------------- /12306Client_MFC/include/json/reader.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTL_JSON_READER_H_INCLUDED 2 | # define CPPTL_JSON_READER_H_INCLUDED 3 | 4 | # include "features.h" 5 | # include "value.h" 6 | # include 7 | # include 8 | # include 9 | # include 10 | 11 | namespace Json { 12 | 13 | /** \brief Unserialize a JSON document into a Value. 14 | * 15 | */ 16 | class JSON_API Reader 17 | { 18 | public: 19 | typedef char Char; 20 | typedef const Char *Location; 21 | 22 | /** \brief Constructs a Reader allowing all features 23 | * for parsing. 24 | */ 25 | Reader(); 26 | 27 | /** \brief Constructs a Reader allowing the specified feature set 28 | * for parsing. 29 | */ 30 | Reader( const Features &features ); 31 | 32 | /** \brief Read a Value from a JSON document. 33 | * \param document UTF-8 encoded string containing the document to read. 34 | * \param root [out] Contains the root value of the document if it was 35 | * successfully parsed. 36 | * \param collectComments \c true to collect comment and allow writing them back during 37 | * serialization, \c false to discard comments. 38 | * This parameter is ignored if Features::allowComments_ 39 | * is \c false. 40 | * \return \c true if the document was successfully parsed, \c false if an error occurred. 41 | */ 42 | bool parse( const std::string &document, 43 | Value &root, 44 | bool collectComments = true ); 45 | 46 | /** \brief Read a Value from a JSON document. 47 | * \param document UTF-8 encoded string containing the document to read. 48 | * \param root [out] Contains the root value of the document if it was 49 | * successfully parsed. 50 | * \param collectComments \c true to collect comment and allow writing them back during 51 | * serialization, \c false to discard comments. 52 | * This parameter is ignored if Features::allowComments_ 53 | * is \c false. 54 | * \return \c true if the document was successfully parsed, \c false if an error occurred. 55 | */ 56 | bool parse( const char *beginDoc, const char *endDoc, 57 | Value &root, 58 | bool collectComments = true ); 59 | 60 | /// \brief Parse from input stream. 61 | /// \see Json::operator>>(std::istream&, Json::Value&). 62 | bool parse( std::istream &is, 63 | Value &root, 64 | bool collectComments = true ); 65 | 66 | /** \brief Returns a user friendly string that list errors in the parsed document. 67 | * \return Formatted error message with the list of errors with their location in 68 | * the parsed document. An empty string is returned if no error occurred 69 | * during parsing. 70 | */ 71 | std::string getFormatedErrorMessages() const; 72 | 73 | private: 74 | enum TokenType 75 | { 76 | tokenEndOfStream = 0, 77 | tokenObjectBegin, 78 | tokenObjectEnd, 79 | tokenArrayBegin, 80 | tokenArrayEnd, 81 | tokenString, 82 | tokenNumber, 83 | tokenTrue, 84 | tokenFalse, 85 | tokenNull, 86 | tokenArraySeparator, 87 | tokenMemberSeparator, 88 | tokenComment, 89 | tokenError 90 | }; 91 | 92 | class Token 93 | { 94 | public: 95 | TokenType type_; 96 | Location start_; 97 | Location end_; 98 | }; 99 | 100 | class ErrorInfo 101 | { 102 | public: 103 | Token token_; 104 | std::string message_; 105 | Location extra_; 106 | }; 107 | 108 | typedef std::deque Errors; 109 | 110 | bool expectToken( TokenType type, Token &token, const char *message ); 111 | bool readToken( Token &token ); 112 | void skipSpaces(); 113 | bool match( Location pattern, 114 | int patternLength ); 115 | bool readComment(); 116 | bool readCStyleComment(); 117 | bool readCppStyleComment(); 118 | bool readString(); 119 | void readNumber(); 120 | bool readValue(); 121 | bool readObject( Token &token ); 122 | bool readArray( Token &token ); 123 | bool decodeNumber( Token &token ); 124 | bool decodeString( Token &token ); 125 | bool decodeString( Token &token, std::string &decoded ); 126 | bool decodeDouble( Token &token ); 127 | bool decodeUnicodeCodePoint( Token &token, 128 | Location ¤t, 129 | Location end, 130 | unsigned int &unicode ); 131 | bool decodeUnicodeEscapeSequence( Token &token, 132 | Location ¤t, 133 | Location end, 134 | unsigned int &unicode ); 135 | bool addError( const std::string &message, 136 | Token &token, 137 | Location extra = 0 ); 138 | bool recoverFromError( TokenType skipUntilToken ); 139 | bool addErrorAndRecover( const std::string &message, 140 | Token &token, 141 | TokenType skipUntilToken ); 142 | void skipUntilSpace(); 143 | Value ¤tValue(); 144 | Char getNextChar(); 145 | void getLocationLineAndColumn( Location location, 146 | int &line, 147 | int &column ) const; 148 | std::string getLocationLineAndColumn( Location location ) const; 149 | void addComment( Location begin, 150 | Location end, 151 | CommentPlacement placement ); 152 | void skipCommentTokens( Token &token ); 153 | 154 | typedef std::stack Nodes; 155 | Nodes nodes_; 156 | Errors errors_; 157 | std::string document_; 158 | Location begin_; 159 | Location end_; 160 | Location current_; 161 | Location lastValueEnd_; 162 | Value *lastValue_; 163 | std::string commentsBefore_; 164 | Features features_; 165 | bool collectComments_; 166 | }; 167 | 168 | /** \brief Read from 'sin' into 'root'. 169 | 170 | Always keep comments from the input JSON. 171 | 172 | This can be used to read a file into a particular sub-object. 173 | For example: 174 | \code 175 | Json::Value root; 176 | cin >> root["dir"]["file"]; 177 | cout << root; 178 | \endcode 179 | Result: 180 | \verbatim 181 | { 182 | "dir": { 183 | "file": { 184 | // The input stream JSON would be nested here. 185 | } 186 | } 187 | } 188 | \endverbatim 189 | \throw std::exception on parse error. 190 | \see Json::operator<<() 191 | */ 192 | std::istream& operator>>( std::istream&, Value& ); 193 | 194 | } // namespace Json 195 | 196 | #endif // CPPTL_JSON_READER_H_INCLUDED 197 | -------------------------------------------------------------------------------- /12306Client_MFC/UrlWrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include "UrlWrapper.h" 4 | 5 | 6 | static const char* FireFox = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"; 7 | static const char* IE7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0C; .NET4.0E)"; 8 | 9 | CUrlWrapper::CUrlWrapper(void) 10 | { 11 | m_pCurlObj = NULL; 12 | m_response.reserve(10240); 13 | } 14 | 15 | 16 | CUrlWrapper::~CUrlWrapper(void) 17 | { 18 | if (m_pCurlObj) 19 | { 20 | ::curl_easy_cleanup(m_pCurlObj); 21 | ::curl_global_cleanup(); 22 | } 23 | } 24 | 25 | 26 | bool CUrlWrapper::Init() 27 | { 28 | if (CURLE_OK != ::curl_global_init(CURL_GLOBAL_ALL) 29 | || NULL == (m_pCurlObj = ::curl_easy_init())) 30 | { 31 | return false; 32 | } 33 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_COOKIEFILE, "./cookies.txt"); 34 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_COOKIEJAR, "./cookies.txt"); 35 | return true; 36 | } 37 | 38 | 39 | bool CUrlWrapper::doHttpPost( const char* url, const char* data, long timeout/* = 10*/) 40 | { 41 | resetOpt(); 42 | //::curl_easy_setopt(m_pCurlObj, CURLOPT_HEADER, withheader); 43 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_URL, url ); 44 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_POST, 1 ); 45 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_POSTFIELDS, data ); 46 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_TIMEOUT, timeout ); 47 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEFUNCTION, CUrlWrapper::processFunc ); 48 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEDATA, this); 49 | return ::curl_easy_perform(m_pCurlObj) == 0 ? true : false; 50 | } 51 | 52 | 53 | bool CUrlWrapper::doHttpGet(const char* url, const char* data, long timeout) 54 | { 55 | size_t urllen = strlen( url ); 56 | size_t datalen = strlen( data ); 57 | char* surl = new char[ urllen + datalen + 1 + 1]; 58 | if(!surl) return false; 59 | //strncpy( surl, url, urllen ); 60 | strncpy_s(surl, urllen + datalen + 1 + 1, url, urllen); 61 | //surl[ urllen ] = '?'; 62 | //strcpy( surl + urllen + 1, data ); 63 | strcpy_s(surl + urllen + 1, datalen+1, data); 64 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_URL, surl ); 65 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HTTPGET, 1 ); 66 | //::curl_easy_setopt( m_pCurlObj, CURLOPT_HEADER, withheader ); 67 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_TIMEOUT, timeout ); 68 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEFUNCTION, CUrlWrapper::processFunc); 69 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEDATA, this ); 70 | CURLcode error_code = ::curl_easy_perform(m_pCurlObj); 71 | delete []surl; 72 | return 0==error_code ? true : false; 73 | } 74 | 75 | bool CUrlWrapper::doHttpsGet(const char* url, long timeout) 76 | { 77 | resetOpt(); 78 | struct curl_slist *headers = NULL; 79 | headers = createHeader(headers); 80 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_URL, url ); 81 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_SSL_VERIFYPEER, 0); 82 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_SSL_VERIFYHOST, 1); 83 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 84 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HTTPGET, 1 ); 85 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HEADER, headers); 86 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_TIMEOUT, timeout ); 87 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_CONNECTTIMEOUT, timeout); 88 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEFUNCTION, CUrlWrapper::processFunc); 89 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEDATA, this); 90 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_NOSIGNAL, 1); 91 | 92 | CURLcode error_code = ::curl_easy_perform(m_pCurlObj); 93 | 94 | curl_slist_free_all(headers); 95 | return 0==error_code ? true : false; 96 | } 97 | 98 | bool CUrlWrapper::doHttpsPost(const char* url, const char* post_data, long timeout/* = 10*/) 99 | { 100 | resetOpt(); 101 | struct curl_slist *headers = NULL; 102 | headers = createHeader(headers); 103 | char header_length[256] = {'\0'}; 104 | strcat_s(header_length, 256, "Content-Length:"); 105 | sprintf_s(header_length+strlen(header_length), 256-strlen(header_length), "%d", strlen(header_length)+strlen(post_data)); 106 | headers = ::curl_slist_append(headers, header_length); 107 | headers = ::curl_slist_append(headers, "Content-Type:application/x-www-form-urlencoded; charset=UTF-8"); 108 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_URL, url ); 109 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_SSL_VERIFYPEER, 0L); 110 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_SSL_VERIFYHOST, 0L); 111 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 112 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_POST, 1 ); 113 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_POSTFIELDS, post_data); 114 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_HEADER, headers); 115 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_TIMEOUT, timeout ); 116 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_CONNECTTIMEOUT, timeout); 117 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEFUNCTION, CUrlWrapper::processFunc); 118 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_WRITEDATA, this); 119 | ::curl_easy_setopt( m_pCurlObj, CURLOPT_NOSIGNAL, 1); 120 | CURLcode error_code = ::curl_easy_perform(m_pCurlObj); 121 | 122 | curl_slist_free_all(headers); 123 | return 0==error_code ? true : false; 124 | } 125 | 126 | 127 | curl_slist* CUrlWrapper::createHeader(curl_slist *headers) 128 | { 129 | char* agent = new char[512]; 130 | memset(agent, 0, 512); 131 | strcpy_s(agent, 512, "User-Agent:"); 132 | strcpy_s(agent + strlen("User-Agent:"), 512 - strlen("User-Agent:"), FireFox); 133 | headers = ::curl_slist_append(headers, "Host:kyfw.12306.cn"); 134 | headers = ::curl_slist_append(headers, agent); 135 | headers = ::curl_slist_append(headers, "Accept:*/*"); 136 | headers = ::curl_slist_append(headers, "Accept-Language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); 137 | headers = ::curl_slist_append(headers, "Accept-Encoding:gzip, deflate"); 138 | headers = ::curl_slist_append(headers, "Connection:keep-alive"); 139 | headers = ::curl_slist_append(headers, "Cache-Control:max-age=0"); 140 | delete[] agent; 141 | return headers; 142 | } 143 | 144 | void CUrlWrapper::resetOpt() 145 | { 146 | m_response.clear(); 147 | ::curl_easy_reset( m_pCurlObj ); 148 | //::curl_easy_setopt( m_pCurlObj, CURLOPT_VERBOSE, 1 );//set this to show debug message 149 | } 150 | 151 | size_t CUrlWrapper::processFunc( void* ptr, size_t size, size_t nmemb, void *usrptr ) 152 | { 153 | CUrlWrapper* p =(CUrlWrapper*) usrptr; 154 | return p->process( ptr, size, nmemb ); 155 | } 156 | 157 | int CUrlWrapper::process( void* data, size_t size, size_t nmemb ) 158 | { 159 | size_t len = size*nmemb; 160 | for (size_t i = 0; i < len; i++) 161 | { 162 | m_response.push_back(((byte*)data)[i]); 163 | } 164 | return len; 165 | } 166 | 167 | 168 | void CUrlWrapper::getRandom(char* code, size_t sizeOfBuffer) 169 | { 170 | srand((unsigned)time(NULL)); 171 | double dcode = (double)rand() / (RAND_MAX+1); 172 | sprintf_s(code, sizeOfBuffer, "%0.16f", dcode); 173 | } 174 | 175 | 176 | size_t CUrlWrapper::getResponseData(void* data, size_t len) 177 | { 178 | size_t length = m_response.size(); 179 | if(!length) 180 | return 0; 181 | ASSERT_POINTER(data, byte); 182 | if(0==memcpy_s(data, len, m_response.data(), length)) 183 | { 184 | return length; 185 | } 186 | else 187 | { 188 | return 0; 189 | } 190 | } 191 | 192 | size_t CUrlWrapper::getResponseLength() 193 | { 194 | return m_response.size(); 195 | } 196 | 197 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/curlbuild.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLBUILD_H 2 | #define __CURL_CURLBUILD_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 http://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 | * Nothing in this file is intended to be modified or adjusted by the 34 | * curl library user nor by the curl library builder. 35 | * 36 | * If you think that something actually needs to be changed, adjusted 37 | * or fixed in this file, then, report it on the libcurl development 38 | * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ 39 | * 40 | * This header file shall only export symbols which are 'curl' or 'CURL' 41 | * prefixed, otherwise public name space would be polluted. 42 | * 43 | * NOTE 2: 44 | * ------- 45 | * 46 | * Right now you might be staring at file include/curl/curlbuild.h.in or 47 | * at file include/curl/curlbuild.h, this is due to the following reason: 48 | * 49 | * On systems capable of running the configure script, the configure process 50 | * will overwrite the distributed include/curl/curlbuild.h file with one that 51 | * is suitable and specific to the library being configured and built, which 52 | * is generated from the include/curl/curlbuild.h.in template file. 53 | * 54 | */ 55 | 56 | /* ================================================================ */ 57 | /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ 58 | /* ================================================================ */ 59 | 60 | #ifdef CURL_SIZEOF_LONG 61 | #error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" 62 | Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined 63 | #endif 64 | 65 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 66 | #error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 67 | Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined 68 | #endif 69 | 70 | #ifdef CURL_SIZEOF_CURL_SOCKLEN_T 71 | #error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 72 | Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined 73 | #endif 74 | 75 | #ifdef CURL_TYPEOF_CURL_OFF_T 76 | #error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 77 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined 78 | #endif 79 | 80 | #ifdef CURL_FORMAT_CURL_OFF_T 81 | #error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" 82 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined 83 | #endif 84 | 85 | #ifdef CURL_FORMAT_CURL_OFF_TU 86 | #error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" 87 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined 88 | #endif 89 | 90 | #ifdef CURL_FORMAT_OFF_T 91 | #error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" 92 | Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined 93 | #endif 94 | 95 | #ifdef CURL_SIZEOF_CURL_OFF_T 96 | #error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 97 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined 98 | #endif 99 | 100 | #ifdef CURL_SUFFIX_CURL_OFF_T 101 | #error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" 102 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined 103 | #endif 104 | 105 | #ifdef CURL_SUFFIX_CURL_OFF_TU 106 | #error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" 107 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined 108 | #endif 109 | 110 | /* ================================================================ */ 111 | /* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ 112 | /* ================================================================ */ 113 | 114 | /* Configure process defines this to 1 when it finds out that system */ 115 | /* header file ws2tcpip.h must be included by the external interface. */ 116 | #undef CURL_PULL_WS2TCPIP_H 117 | #ifdef CURL_PULL_WS2TCPIP_H 118 | # ifndef WIN32_LEAN_AND_MEAN 119 | # define WIN32_LEAN_AND_MEAN 120 | # endif 121 | # include 122 | # include 123 | # include 124 | #endif 125 | 126 | /* Configure process defines this to 1 when it finds out that system */ 127 | /* header file sys/types.h must be included by the external interface. */ 128 | #undef CURL_PULL_SYS_TYPES_H 129 | #ifdef CURL_PULL_SYS_TYPES_H 130 | # include 131 | #endif 132 | 133 | /* Configure process defines this to 1 when it finds out that system */ 134 | /* header file stdint.h must be included by the external interface. */ 135 | #undef CURL_PULL_STDINT_H 136 | #ifdef CURL_PULL_STDINT_H 137 | # include 138 | #endif 139 | 140 | /* Configure process defines this to 1 when it finds out that system */ 141 | /* header file inttypes.h must be included by the external interface. */ 142 | #undef CURL_PULL_INTTYPES_H 143 | #ifdef CURL_PULL_INTTYPES_H 144 | # include 145 | #endif 146 | 147 | /* Configure process defines this to 1 when it finds out that system */ 148 | /* header file sys/socket.h must be included by the external interface. */ 149 | #undef CURL_PULL_SYS_SOCKET_H 150 | #ifdef CURL_PULL_SYS_SOCKET_H 151 | # include 152 | #endif 153 | 154 | /* Configure process defines this to 1 when it finds out that system */ 155 | /* header file sys/poll.h must be included by the external interface. */ 156 | #undef CURL_PULL_SYS_POLL_H 157 | #ifdef CURL_PULL_SYS_POLL_H 158 | # include 159 | #endif 160 | 161 | /* The size of `long', as computed by sizeof. */ 162 | #undef CURL_SIZEOF_LONG 163 | 164 | /* Integral data type used for curl_socklen_t. */ 165 | #undef CURL_TYPEOF_CURL_SOCKLEN_T 166 | 167 | /* The size of `curl_socklen_t', as computed by sizeof. */ 168 | #undef CURL_SIZEOF_CURL_SOCKLEN_T 169 | 170 | /* Data type definition of curl_socklen_t. */ 171 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; 172 | 173 | /* Signed integral data type used for curl_off_t. */ 174 | #undef CURL_TYPEOF_CURL_OFF_T 175 | 176 | /* Data type definition of curl_off_t. */ 177 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; 178 | 179 | /* curl_off_t formatting string directive without "%" conversion specifier. */ 180 | #undef CURL_FORMAT_CURL_OFF_T 181 | 182 | /* unsigned curl_off_t formatting string without "%" conversion specifier. */ 183 | #undef CURL_FORMAT_CURL_OFF_TU 184 | 185 | /* curl_off_t formatting string directive with "%" conversion specifier. */ 186 | #undef CURL_FORMAT_OFF_T 187 | 188 | /* The size of `curl_off_t', as computed by sizeof. */ 189 | #undef CURL_SIZEOF_CURL_OFF_T 190 | 191 | /* curl_off_t constant suffix. */ 192 | #undef CURL_SUFFIX_CURL_OFF_T 193 | 194 | /* unsigned curl_off_t constant suffix. */ 195 | #undef CURL_SUFFIX_CURL_OFF_TU 196 | 197 | #endif /* __CURL_CURLBUILD_H */ 198 | -------------------------------------------------------------------------------- /12306Client_MFC/12306Client_MFC.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {6855A594-5AD9-4AE7-8D67-7AB611ABD19F} 15 | My12306Client_MFC 16 | MFCProj 17 | 18 | 19 | 20 | Application 21 | true 22 | v110_xp 23 | Unicode 24 | Static 25 | 26 | 27 | Application 28 | false 29 | v110_xp 30 | true 31 | Unicode 32 | Static 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | .\include;$(IncludePath) 47 | .\lib\debug;$(LibraryPath) 48 | $(ExecutablePath) 49 | 50 | 51 | false 52 | .\include;$(IncludePath) 53 | .\lib\release;$(LibraryPath) 54 | 55 | 56 | 57 | Use 58 | Level3 59 | Disabled 60 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) 61 | true 62 | 63 | 64 | Windows 65 | true 66 | libcurl.lib;json_vc71_libmtd.lib;%(AdditionalDependencies) 67 | 68 | 69 | 70 | 71 | false 72 | true 73 | _DEBUG;%(PreprocessorDefinitions) 74 | 75 | 76 | 0x0804 77 | _DEBUG;%(PreprocessorDefinitions) 78 | $(IntDir);%(AdditionalIncludeDirectories) 79 | 80 | 81 | 82 | 83 | Level3 84 | Use 85 | MaxSpeed 86 | true 87 | true 88 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) 89 | true 90 | 91 | 92 | Windows 93 | true 94 | true 95 | true 96 | libcurl.lib;json_vc71_libmt.lib;%(AdditionalDependencies) 97 | 98 | 99 | false 100 | true 101 | NDEBUG;%(PreprocessorDefinitions) 102 | 103 | 104 | 0x0804 105 | NDEBUG;%(PreprocessorDefinitions) 106 | $(IntDir);%(AdditionalIncludeDirectories) 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | Create 141 | Create 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/curlbuild.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLBUILD_H 2 | #define __CURL_CURLBUILD_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 http://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 | * Nothing in this file is intended to be modified or adjusted by the 34 | * curl library user nor by the curl library builder. 35 | * 36 | * If you think that something actually needs to be changed, adjusted 37 | * or fixed in this file, then, report it on the libcurl development 38 | * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ 39 | * 40 | * This header file shall only export symbols which are 'curl' or 'CURL' 41 | * prefixed, otherwise public name space would be polluted. 42 | * 43 | * NOTE 2: 44 | * ------- 45 | * 46 | * Right now you might be staring at file include/curl/curlbuild.h.in or 47 | * at file include/curl/curlbuild.h, this is due to the following reason: 48 | * 49 | * On systems capable of running the configure script, the configure process 50 | * will overwrite the distributed include/curl/curlbuild.h file with one that 51 | * is suitable and specific to the library being configured and built, which 52 | * is generated from the include/curl/curlbuild.h.in template file. 53 | * 54 | */ 55 | 56 | /* ================================================================ */ 57 | /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ 58 | /* ================================================================ */ 59 | 60 | #ifdef CURL_SIZEOF_LONG 61 | #error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" 62 | Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined 63 | #endif 64 | 65 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 66 | #error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 67 | Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined 68 | #endif 69 | 70 | #ifdef CURL_SIZEOF_CURL_SOCKLEN_T 71 | #error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" 72 | Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined 73 | #endif 74 | 75 | #ifdef CURL_TYPEOF_CURL_OFF_T 76 | #error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 77 | Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined 78 | #endif 79 | 80 | #ifdef CURL_FORMAT_CURL_OFF_T 81 | #error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" 82 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined 83 | #endif 84 | 85 | #ifdef CURL_FORMAT_CURL_OFF_TU 86 | #error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" 87 | Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined 88 | #endif 89 | 90 | #ifdef CURL_FORMAT_OFF_T 91 | #error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" 92 | Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined 93 | #endif 94 | 95 | #ifdef CURL_SIZEOF_CURL_OFF_T 96 | #error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" 97 | Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined 98 | #endif 99 | 100 | #ifdef CURL_SUFFIX_CURL_OFF_T 101 | #error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" 102 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined 103 | #endif 104 | 105 | #ifdef CURL_SUFFIX_CURL_OFF_TU 106 | #error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" 107 | Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined 108 | #endif 109 | 110 | /* ================================================================ */ 111 | /* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ 112 | /* ================================================================ */ 113 | 114 | /* Configure process defines this to 1 when it finds out that system */ 115 | /* header file ws2tcpip.h must be included by the external interface. */ 116 | #cmakedefine CURL_PULL_WS2TCPIP_H 117 | #ifdef CURL_PULL_WS2TCPIP_H 118 | # ifndef WIN32_LEAN_AND_MEAN 119 | # define WIN32_LEAN_AND_MEAN 120 | # endif 121 | # include 122 | # include 123 | # include 124 | #endif 125 | 126 | /* Configure process defines this to 1 when it finds out that system */ 127 | /* header file sys/types.h must be included by the external interface. */ 128 | #cmakedefine CURL_PULL_SYS_TYPES_H 129 | #ifdef CURL_PULL_SYS_TYPES_H 130 | # include 131 | #endif 132 | 133 | /* Configure process defines this to 1 when it finds out that system */ 134 | /* header file stdint.h must be included by the external interface. */ 135 | #cmakedefine CURL_PULL_STDINT_H 136 | #ifdef CURL_PULL_STDINT_H 137 | # include 138 | #endif 139 | 140 | /* Configure process defines this to 1 when it finds out that system */ 141 | /* header file inttypes.h must be included by the external interface. */ 142 | #cmakedefine CURL_PULL_INTTYPES_H 143 | #ifdef CURL_PULL_INTTYPES_H 144 | # include 145 | #endif 146 | 147 | /* Configure process defines this to 1 when it finds out that system */ 148 | /* header file sys/socket.h must be included by the external interface. */ 149 | #cmakedefine CURL_PULL_SYS_SOCKET_H 150 | #ifdef CURL_PULL_SYS_SOCKET_H 151 | # include 152 | #endif 153 | 154 | /* Configure process defines this to 1 when it finds out that system */ 155 | /* header file sys/poll.h must be included by the external interface. */ 156 | #cmakedefine CURL_PULL_SYS_POLL_H 157 | #ifdef CURL_PULL_SYS_POLL_H 158 | # include 159 | #endif 160 | 161 | /* The size of `long', as computed by sizeof. */ 162 | #define CURL_SIZEOF_LONG ${CURL_SIZEOF_LONG} 163 | 164 | /* Integral data type used for curl_socklen_t. */ 165 | #define CURL_TYPEOF_CURL_SOCKLEN_T ${CURL_TYPEOF_CURL_SOCKLEN_T} 166 | 167 | /* The size of `curl_socklen_t', as computed by sizeof. */ 168 | #define CURL_SIZEOF_CURL_SOCKLEN_T ${CURL_SIZEOF_CURL_SOCKLEN_T} 169 | 170 | /* Data type definition of curl_socklen_t. */ 171 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; 172 | 173 | /* Signed integral data type used for curl_off_t. */ 174 | #define CURL_TYPEOF_CURL_OFF_T ${CURL_TYPEOF_CURL_OFF_T} 175 | 176 | /* Data type definition of curl_off_t. */ 177 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; 178 | 179 | /* curl_off_t formatting string directive without "%" conversion specifier. */ 180 | #define CURL_FORMAT_CURL_OFF_T "${CURL_FORMAT_CURL_OFF_T}" 181 | 182 | /* unsigned curl_off_t formatting string without "%" conversion specifier. */ 183 | #define CURL_FORMAT_CURL_OFF_TU "${CURL_FORMAT_CURL_OFF_TU}" 184 | 185 | /* curl_off_t formatting string directive with "%" conversion specifier. */ 186 | #define CURL_FORMAT_OFF_T "${CURL_FORMAT_OFF_T}" 187 | 188 | /* The size of `curl_off_t', as computed by sizeof. */ 189 | #define CURL_SIZEOF_CURL_OFF_T ${CURL_SIZEOF_CURL_OFF_T} 190 | 191 | /* curl_off_t constant suffix. */ 192 | #define CURL_SUFFIX_CURL_OFF_T ${CURL_SUFFIX_CURL_OFF_T} 193 | 194 | /* unsigned curl_off_t constant suffix. */ 195 | #define CURL_SUFFIX_CURL_OFF_TU ${CURL_SUFFIX_CURL_OFF_TU} 196 | 197 | #endif /* __CURL_CURLBUILD_H */ 198 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/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 http://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 | * http://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 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/multi.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MULTI_H 2 | #define __CURL_MULTI_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, 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 http://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 | typedef void CURLM; 56 | 57 | typedef enum { 58 | CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or 59 | curl_multi_socket*() soon */ 60 | CURLM_OK, 61 | CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ 62 | CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ 63 | CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ 64 | CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ 65 | CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ 66 | CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ 67 | CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was 68 | attempted to get added - again */ 69 | CURLM_LAST 70 | } CURLMcode; 71 | 72 | /* just to make code nicer when using curl_multi_socket() you can now check 73 | for CURLM_CALL_MULTI_SOCKET too in the same style it works for 74 | curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ 75 | #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM 76 | 77 | typedef enum { 78 | CURLMSG_NONE, /* first, not used */ 79 | CURLMSG_DONE, /* This easy handle has completed. 'result' contains 80 | the CURLcode of the transfer */ 81 | CURLMSG_LAST /* last, not used */ 82 | } CURLMSG; 83 | 84 | struct CURLMsg { 85 | CURLMSG msg; /* what this message means */ 86 | CURL *easy_handle; /* the handle it concerns */ 87 | union { 88 | void *whatever; /* message-specific data */ 89 | CURLcode result; /* return code for transfer */ 90 | } data; 91 | }; 92 | typedef struct CURLMsg CURLMsg; 93 | 94 | /* Based on poll(2) structure and values. 95 | * We don't use pollfd and POLL* constants explicitly 96 | * to cover platforms without poll(). */ 97 | #define CURL_WAIT_POLLIN 0x0001 98 | #define CURL_WAIT_POLLPRI 0x0002 99 | #define CURL_WAIT_POLLOUT 0x0004 100 | 101 | struct curl_waitfd { 102 | curl_socket_t fd; 103 | short events; 104 | short revents; /* not supported yet */ 105 | }; 106 | 107 | /* 108 | * Name: curl_multi_init() 109 | * 110 | * Desc: inititalize multi-style curl usage 111 | * 112 | * Returns: a new CURLM handle to use in all 'curl_multi' functions. 113 | */ 114 | CURL_EXTERN CURLM *curl_multi_init(void); 115 | 116 | /* 117 | * Name: curl_multi_add_handle() 118 | * 119 | * Desc: add a standard curl handle to the multi stack 120 | * 121 | * Returns: CURLMcode type, general multi error code. 122 | */ 123 | CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, 124 | CURL *curl_handle); 125 | 126 | /* 127 | * Name: curl_multi_remove_handle() 128 | * 129 | * Desc: removes a curl handle from the multi stack again 130 | * 131 | * Returns: CURLMcode type, general multi error code. 132 | */ 133 | CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, 134 | CURL *curl_handle); 135 | 136 | /* 137 | * Name: curl_multi_fdset() 138 | * 139 | * Desc: Ask curl for its fd_set sets. The app can use these to select() or 140 | * poll() on. We want curl_multi_perform() called as soon as one of 141 | * them are ready. 142 | * 143 | * Returns: CURLMcode type, general multi error code. 144 | */ 145 | CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, 146 | fd_set *read_fd_set, 147 | fd_set *write_fd_set, 148 | fd_set *exc_fd_set, 149 | int *max_fd); 150 | 151 | /* 152 | * Name: curl_multi_wait() 153 | * 154 | * Desc: Poll on all fds within a CURLM set as well as any 155 | * additional fds passed to the function. 156 | * 157 | * Returns: CURLMcode type, general multi error code. 158 | */ 159 | CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, 160 | struct curl_waitfd extra_fds[], 161 | unsigned int extra_nfds, 162 | int timeout_ms, 163 | int *ret); 164 | 165 | /* 166 | * Name: curl_multi_perform() 167 | * 168 | * Desc: When the app thinks there's data available for curl it calls this 169 | * function to read/write whatever there is right now. This returns 170 | * as soon as the reads and writes are done. This function does not 171 | * require that there actually is data available for reading or that 172 | * data can be written, it can be called just in case. It returns 173 | * the number of handles that still transfer data in the second 174 | * argument's integer-pointer. 175 | * 176 | * Returns: CURLMcode type, general multi error code. *NOTE* that this only 177 | * returns errors etc regarding the whole multi stack. There might 178 | * still have occurred problems on invidual transfers even when this 179 | * returns OK. 180 | */ 181 | CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, 182 | int *running_handles); 183 | 184 | /* 185 | * Name: curl_multi_cleanup() 186 | * 187 | * Desc: Cleans up and removes a whole multi stack. It does not free or 188 | * touch any individual easy handles in any way. We need to define 189 | * in what state those handles will be if this function is called 190 | * in the middle of a transfer. 191 | * 192 | * Returns: CURLMcode type, general multi error code. 193 | */ 194 | CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); 195 | 196 | /* 197 | * Name: curl_multi_info_read() 198 | * 199 | * Desc: Ask the multi handle if there's any messages/informationals from 200 | * the individual transfers. Messages include informationals such as 201 | * error code from the transfer or just the fact that a transfer is 202 | * completed. More details on these should be written down as well. 203 | * 204 | * Repeated calls to this function will return a new struct each 205 | * time, until a special "end of msgs" struct is returned as a signal 206 | * that there is no more to get at this point. 207 | * 208 | * The data the returned pointer points to will not survive calling 209 | * curl_multi_cleanup(). 210 | * 211 | * The 'CURLMsg' struct is meant to be very simple and only contain 212 | * very basic informations. If more involved information is wanted, 213 | * we will provide the particular "transfer handle" in that struct 214 | * and that should/could/would be used in subsequent 215 | * curl_easy_getinfo() calls (or similar). The point being that we 216 | * must never expose complex structs to applications, as then we'll 217 | * undoubtably get backwards compatibility problems in the future. 218 | * 219 | * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out 220 | * of structs. It also writes the number of messages left in the 221 | * queue (after this read) in the integer the second argument points 222 | * to. 223 | */ 224 | CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, 225 | int *msgs_in_queue); 226 | 227 | /* 228 | * Name: curl_multi_strerror() 229 | * 230 | * Desc: The curl_multi_strerror function may be used to turn a CURLMcode 231 | * value into the equivalent human readable error string. This is 232 | * useful for printing meaningful error messages. 233 | * 234 | * Returns: A pointer to a zero-terminated error message. 235 | */ 236 | CURL_EXTERN const char *curl_multi_strerror(CURLMcode); 237 | 238 | /* 239 | * Name: curl_multi_socket() and 240 | * curl_multi_socket_all() 241 | * 242 | * Desc: An alternative version of curl_multi_perform() that allows the 243 | * application to pass in one of the file descriptors that have been 244 | * detected to have "action" on them and let libcurl perform. 245 | * See man page for details. 246 | */ 247 | #define CURL_POLL_NONE 0 248 | #define CURL_POLL_IN 1 249 | #define CURL_POLL_OUT 2 250 | #define CURL_POLL_INOUT 3 251 | #define CURL_POLL_REMOVE 4 252 | 253 | #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD 254 | 255 | #define CURL_CSELECT_IN 0x01 256 | #define CURL_CSELECT_OUT 0x02 257 | #define CURL_CSELECT_ERR 0x04 258 | 259 | typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ 260 | curl_socket_t s, /* socket */ 261 | int what, /* see above */ 262 | void *userp, /* private callback 263 | pointer */ 264 | void *socketp); /* private socket 265 | pointer */ 266 | /* 267 | * Name: curl_multi_timer_callback 268 | * 269 | * Desc: Called by libcurl whenever the library detects a change in the 270 | * maximum number of milliseconds the app is allowed to wait before 271 | * curl_multi_socket() or curl_multi_perform() must be called 272 | * (to allow libcurl's timed events to take place). 273 | * 274 | * Returns: The callback should return zero. 275 | */ 276 | typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ 277 | long timeout_ms, /* see above */ 278 | void *userp); /* private callback 279 | pointer */ 280 | 281 | CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, 282 | int *running_handles); 283 | 284 | CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, 285 | curl_socket_t s, 286 | int ev_bitmask, 287 | int *running_handles); 288 | 289 | CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, 290 | int *running_handles); 291 | 292 | #ifndef CURL_ALLOW_OLD_MULTI_SOCKET 293 | /* This macro below was added in 7.16.3 to push users who recompile to use 294 | the new curl_multi_socket_action() instead of the old curl_multi_socket() 295 | */ 296 | #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) 297 | #endif 298 | 299 | /* 300 | * Name: curl_multi_timeout() 301 | * 302 | * Desc: Returns the maximum number of milliseconds the app is allowed to 303 | * wait before curl_multi_socket() or curl_multi_perform() must be 304 | * called (to allow libcurl's timed events to take place). 305 | * 306 | * Returns: CURLM error code. 307 | */ 308 | CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, 309 | long *milliseconds); 310 | 311 | #undef CINIT /* re-using the same name as in curl.h */ 312 | 313 | #ifdef CURL_ISOCPP 314 | #define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num 315 | #else 316 | /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ 317 | #define LONG CURLOPTTYPE_LONG 318 | #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT 319 | #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT 320 | #define OFF_T CURLOPTTYPE_OFF_T 321 | #define CINIT(name,type,number) CURLMOPT_/**/name = type + number 322 | #endif 323 | 324 | typedef enum { 325 | /* This is the socket callback function pointer */ 326 | CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), 327 | 328 | /* This is the argument passed to the socket callback */ 329 | CINIT(SOCKETDATA, OBJECTPOINT, 2), 330 | 331 | /* set to 1 to enable pipelining for this multi handle */ 332 | CINIT(PIPELINING, LONG, 3), 333 | 334 | /* This is the timer callback function pointer */ 335 | CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), 336 | 337 | /* This is the argument passed to the timer callback */ 338 | CINIT(TIMERDATA, OBJECTPOINT, 5), 339 | 340 | /* maximum number of entries in the connection cache */ 341 | CINIT(MAXCONNECTS, LONG, 6), 342 | 343 | /* maximum number of (pipelining) connections to one host */ 344 | CINIT(MAX_HOST_CONNECTIONS, LONG, 7), 345 | 346 | /* maximum number of requests in a pipeline */ 347 | CINIT(MAX_PIPELINE_LENGTH, LONG, 8), 348 | 349 | /* a connection with a content-length longer than this 350 | will not be considered for pipelining */ 351 | CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9), 352 | 353 | /* a connection with a chunk length longer than this 354 | will not be considered for pipelining */ 355 | CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10), 356 | 357 | /* a list of site names(+port) that are blacklisted from 358 | pipelining */ 359 | CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11), 360 | 361 | /* a list of server types that are blacklisted from 362 | pipelining */ 363 | CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12), 364 | 365 | /* maximum number of open connections in total */ 366 | CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13), 367 | 368 | CURLMOPT_LASTENTRY /* the last unused */ 369 | } CURLMoption; 370 | 371 | 372 | /* 373 | * Name: curl_multi_setopt() 374 | * 375 | * Desc: Sets options for the multi handle. 376 | * 377 | * Returns: CURLM error code. 378 | */ 379 | CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, 380 | CURLMoption option, ...); 381 | 382 | 383 | /* 384 | * Name: curl_multi_assign() 385 | * 386 | * Desc: This function sets an association in the multi handle between the 387 | * given socket and a private pointer of the application. This is 388 | * (only) useful for curl_multi_socket uses. 389 | * 390 | * Returns: CURLM error code. 391 | */ 392 | CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, 393 | curl_socket_t sockfd, void *sockp); 394 | 395 | #ifdef __cplusplus 396 | } /* end of extern "C" */ 397 | #endif 398 | 399 | #endif 400 | -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/curlbuild.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLBUILD_H 2 | #define __CURL_CURLBUILD_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, 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 http://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: http://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(__ILP32__) || \ 531 | defined(__i386__) || defined(__ppc__) || defined(__arm__) 532 | # define CURL_SIZEOF_LONG 4 533 | # define CURL_TYPEOF_CURL_OFF_T long long 534 | # define CURL_FORMAT_CURL_OFF_T "lld" 535 | # define CURL_FORMAT_CURL_OFF_TU "llu" 536 | # define CURL_FORMAT_OFF_T "%lld" 537 | # define CURL_SIZEOF_CURL_OFF_T 8 538 | # define CURL_SUFFIX_CURL_OFF_T LL 539 | # define CURL_SUFFIX_CURL_OFF_TU ULL 540 | # elif defined(__LP64__) || \ 541 | defined(__x86_64__) || defined(__ppc64__) 542 | # define CURL_SIZEOF_LONG 8 543 | # define CURL_TYPEOF_CURL_OFF_T long 544 | # define CURL_FORMAT_CURL_OFF_T "ld" 545 | # define CURL_FORMAT_CURL_OFF_TU "lu" 546 | # define CURL_FORMAT_OFF_T "%ld" 547 | # define CURL_SIZEOF_CURL_OFF_T 8 548 | # define CURL_SUFFIX_CURL_OFF_T L 549 | # define CURL_SUFFIX_CURL_OFF_TU UL 550 | # endif 551 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 552 | # define CURL_SIZEOF_CURL_SOCKLEN_T 4 553 | # define CURL_PULL_SYS_TYPES_H 1 554 | # define CURL_PULL_SYS_SOCKET_H 1 555 | 556 | #else 557 | # error "Unknown non-configure build target!" 558 | Error Compilation_aborted_Unknown_non_configure_build_target 559 | #endif 560 | 561 | /* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ 562 | /* sys/types.h is required here to properly make type definitions below. */ 563 | #ifdef CURL_PULL_SYS_TYPES_H 564 | # include 565 | #endif 566 | 567 | /* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ 568 | /* sys/socket.h is required here to properly make type definitions below. */ 569 | #ifdef CURL_PULL_SYS_SOCKET_H 570 | # include 571 | #endif 572 | 573 | /* Data type definition of curl_socklen_t. */ 574 | 575 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 576 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; 577 | #endif 578 | 579 | /* Data type definition of curl_off_t. */ 580 | 581 | #ifdef CURL_TYPEOF_CURL_OFF_T 582 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; 583 | #endif 584 | 585 | #endif /* __CURL_CURLBUILD_H */ 586 | -------------------------------------------------------------------------------- /12306Client_MFC/TBListCtrl.cpp: -------------------------------------------------------------------------------- 1 | // TBListCtrl.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TBListCtrl.h" 6 | #include 7 | #include 8 | 9 | #include "TBColorButton.h" 10 | // CTBListCtrl 11 | HHOOK CTBListCtrl::m_hHook = NULL; 12 | CWnd* CTBListCtrl::m_pWnd; 13 | 14 | 15 | #ifdef _DEBUG 16 | #define new DEBUG_NEW 17 | #endif 18 | 19 | IMPLEMENT_DYNAMIC(CTBListCtrl, CListCtrl) 20 | 21 | CTBListCtrl::CTBListCtrl() 22 | :m_dwRowHeight(0x20), m_clrLineColor(RGB(0xC0,0xFF,0x3E)), 23 | m_clrSelectedRowColor(RGB(0x87,0xce,0xeb)), 24 | m_dwFontWidth(0), 25 | m_dwFontHeight(12) 26 | { 27 | m_pWnd = this; 28 | m_dwExStyle = 0; 29 | } 30 | 31 | CTBListCtrl::~CTBListCtrl() 32 | { 33 | } 34 | 35 | 36 | BEGIN_MESSAGE_MAP(CTBListCtrl, CListCtrl) 37 | //ON_WM_MEASUREITEM() 38 | ON_WM_MEASUREITEM_REFLECT() 39 | ON_WM_DESTROY() 40 | ON_WM_ERASEBKGND() 41 | //ON_WM_HSCROLL() 42 | //ON_WM_VSCROLL() 43 | ON_WM_PAINT() 44 | ON_NOTIFY_REFLECT_EX(LVN_ENDSCROLL, &CTBListCtrl::OnLvnEndScroll) 45 | ON_NOTIFY_REFLECT_EX(NM_CLICK, &CTBListCtrl::OnNMClick) 46 | //ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CTBListCtrl::OnNMCustomDraw) 47 | ON_MESSAGE(BN_CLICKED, &CTBListCtrl::OnBnClickedCallBack) 48 | END_MESSAGE_MAP() 49 | 50 | 51 | 52 | // CTBListCtrl message handlers 53 | 54 | 55 | void CTBListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 56 | { 57 | ASSERT(lpDrawItemStruct->hDC); 58 | DrawNormalItem(lpDrawItemStruct); 59 | CRect rect; 60 | GetClientRect(&rect); 61 | CRect lastRect; 62 | GetItemRect(GetItemCount()-1, &lastRect, LVIR_BOUNDS); 63 | 64 | if (lastRect.bottom < rect.bottom) 65 | { 66 | rect.top = lastRect.bottom + 1; 67 | CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); 68 | CBrush tmpBrush; 69 | tmpBrush.CreateSolidBrush(DEFAULT_NORMAL_BK_COLOR); 70 | pDC->FillRect(&rect, &tmpBrush); 71 | tmpBrush.DeleteObject(); 72 | } 73 | } 74 | 75 | 76 | BOOL CTBListCtrl::IsItemVisible(int iIndex) 77 | { 78 | const int iTopIndex = GetTopIndex(); 79 | const int iBottomIndex = iTopIndex + GetCountPerPage(); 80 | return !(iIndex < iTopIndex || iIndex > iBottomIndex); 81 | } 82 | 83 | 84 | void CTBListCtrl::DrawNormalItem(LPDRAWITEMSTRUCT lpDrawItem) 85 | { 86 | ASSERT(ODT_LISTVIEW == lpDrawItem->CtlType); 87 | if(!IsItemVisible(lpDrawItem->itemID)) return; 88 | ItemMap::iterator it = m_mapItemInfo.find(lpDrawItem->itemID); 89 | ASSERT(it != m_mapItemInfo.end()); 90 | PITEM_INFO pstItem = it->second; 91 | CDC *pWholeDC = new CDC; 92 | pWholeDC->Attach(lpDrawItem->hDC); 93 | CRect clientRect; 94 | GetClientRect(&clientRect); 95 | 96 | CDC memDC; 97 | CBitmap memBitmap; 98 | VERIFY(memDC.CreateCompatibleDC(pWholeDC)); 99 | memBitmap.CreateCompatibleBitmap(pWholeDC, clientRect.Width(), clientRect.Height()); 100 | CBitmap* pOldBmp = memDC.SelectObject(&memBitmap); 101 | memDC.SetBkMode(TRANSPARENT); 102 | 103 | RECT rectDraw = {0}; 104 | const CRect rectDrawItem = lpDrawItem->rcItem; 105 | 106 | lpDrawItem->rcItem.left = 0; 107 | rectDraw = lpDrawItem->rcItem; 108 | rectDraw.right = clientRect.right; 109 | 110 | CBrush tmpBrush; 111 | tmpBrush.CreateSolidBrush(pstItem->clrBkColor); 112 | memDC.FillRect(&rectDraw, &tmpBrush); 113 | if (lpDrawItem->itemState & ODS_SELECTED) 114 | { 115 | //tmpBrush.CreateSolidBrush(m_clrSelectedRowColor); 116 | //memDC.DrawEdge(&rectDraw, EDGE_RAISED, BF_FLAT); 117 | memDC.DrawFocusRect(&rectDraw); 118 | } 119 | else 120 | { 121 | //tmpBrush.CreateSolidBrush(pstItem->clrBkColor); 122 | /*memDC.FillRect(&rectDraw, &tmpBrush); 123 | tmpBrush.DeleteObject();*/ 124 | } 125 | 126 | tmpBrush.DeleteObject(); 127 | 128 | if (GetExtendedStyle() & LVS_EX_CHECKBOXES) 129 | { 130 | CRect subRect; 131 | GetSubItemRect(lpDrawItem->itemID, 0, LVIR_ICON, subRect); 132 | 133 | subRect.left = rectDrawItem.left + 3; 134 | subRect.right = subRect.left + 12; 135 | 136 | if (pstItem->bSelected) 137 | { 138 | memDC.DrawFrameControl(&subRect, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_CHECKED|DFCS_ADJUSTRECT|DFCS_FLAT); 139 | } 140 | else 141 | { 142 | memDC.DrawFrameControl(&subRect, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_ADJUSTRECT|DFCS_MONO); 143 | } 144 | } 145 | 146 | RECT bottomLine(rectDraw); 147 | bottomLine.top = rectDraw.bottom - 1; 148 | tmpBrush.CreateSolidBrush(m_clrLineColor); 149 | memDC.FillRect(&bottomLine, &tmpBrush); 150 | tmpBrush.DeleteObject(); 151 | 152 | int iCount = GetHeaderCtrl()->GetItemCount(); 153 | CRect subRect; 154 | for (int i = 0; i < iCount; ++i) 155 | { 156 | if (0 == i) 157 | { 158 | GetFirstItemRect(lpDrawItem->itemID, &subRect); 159 | } 160 | else 161 | { 162 | GetSubItemRect(lpDrawItem->itemID, i, LVIR_LABEL, subRect); 163 | } 164 | CString strTxt(GetItemText(lpDrawItem->itemID, i)); 165 | if (!strTxt.IsEmpty()) 166 | { 167 | memDC.SetTextColor(GetItemTextColor(lpDrawItem->itemID, i)); 168 | CFont* pFont = GetFont(); 169 | LOGFONT lf; 170 | pFont->GetLogFont(&lf); 171 | CFont newFont; 172 | LOGFONT newLf = lf; 173 | newLf.lfWidth = m_dwFontWidth; 174 | newLf.lfHeight = m_dwFontHeight; 175 | newFont.CreateFontIndirect(&newLf); 176 | HFONT hOldFont = (HFONT)memDC.SelectObject(newFont); 177 | subRect.OffsetRect(2,0); 178 | memDC.DrawText(strTxt, &subRect, DT_SINGLELINE | DT_VCENTER 179 | | DT_LEFT | DT_NOCLIP | DT_END_ELLIPSIS); 180 | memDC.SelectObject(hOldFont); 181 | newFont.DeleteObject(); 182 | } 183 | } 184 | 185 | rectDraw.left = lpDrawItem->rcItem.left; 186 | rectDraw.right = clientRect.right; 187 | 188 | pWholeDC->BitBlt(rectDraw.left, rectDraw.top, clientRect.Width(), 189 | rectDraw.bottom - rectDraw.top, &memDC, rectDraw.left, rectDraw.top, SRCCOPY); 190 | memDC.SelectObject(pOldBmp); 191 | memBitmap.DeleteObject(); 192 | memDC.DeleteDC(); 193 | pWholeDC->Detach(); 194 | delete pWholeDC; 195 | } 196 | 197 | 198 | void CTBListCtrl::GetFirstItemRect(int iItem, LPRECT pRect) 199 | { 200 | ZeroMemory(pRect, sizeof(RECT)); 201 | 202 | int iCount = GetHeaderCtrl()->GetItemCount(); 203 | if (iCount <= 1) return; 204 | 205 | if (!GetItemRect(iItem, pRect, LVIR_BOUNDS)) return; 206 | 207 | CRect tmpRect; 208 | if (!GetSubItemRect(iItem, 0, LVIR_LABEL, tmpRect)) return; 209 | pRect->right = tmpRect.right; 210 | pRect->left += 2; 211 | } 212 | 213 | 214 | COLORREF CTBListCtrl::GetItemTextColor(int iItem, int iSubItem) 215 | { 216 | map::iterator it = m_mapItemInfo.find(iItem); 217 | if (m_mapItemInfo.end() == it) 218 | { 219 | return DEFAULT_NORMAL_TEXT_COLOR; 220 | } 221 | else 222 | { 223 | list::iterator itSub = it->second->listSubItem.begin(); 224 | list::iterator itSubEnd = it->second->listSubItem.end(); 225 | for (; itSub != itSubEnd; ++itSub) 226 | { 227 | if (itSub->iSubItem == iSubItem) 228 | { 229 | return itSub->clrTextColor; 230 | } 231 | } 232 | } 233 | return DEFAULT_NORMAL_TEXT_COLOR; 234 | } 235 | 236 | 237 | COLORREF CTBListCtrl::GetItemBkColor(int iItem) 238 | { 239 | 240 | map::iterator it = m_mapItemInfo.find(iItem); 241 | if (m_mapItemInfo.end() == it) 242 | { 243 | return DEFAULT_NORMAL_BK_COLOR; 244 | } 245 | return it->second->clrBkColor; 246 | } 247 | 248 | 249 | int CTBListCtrl::InsertItem(int iItem, LPCTSTR lpszItem, COLORREF clrBkColor, COLORREF clrTextColor /* = DEFAULT_NORMAL_TEXT_COLOR */) 250 | { 251 | if (iItem > GetItemCount()) 252 | { 253 | return -1; 254 | } 255 | 256 | PITEM_INFO pItemInfo = new ITEM_INFO; 257 | pItemInfo->clrBkColor = clrBkColor; 258 | pItemInfo->clrNormalColor = clrTextColor; 259 | pItemInfo->bSelected = false; 260 | SUBITEM_INFO subItem; 261 | subItem.iSubItem = 0; 262 | subItem.clrTextColor = clrTextColor; 263 | subItem.clrBkColor = clrBkColor; 264 | subItem.pBtn = NULL; 265 | subItem.strNormal = lpszItem; 266 | pItemInfo->listSubItem.push_back(subItem); 267 | 268 | ItemMap::iterator it = m_mapItemInfo.find(iItem); 269 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 270 | if(it == itEnd) 271 | { 272 | m_mapItemInfo.insert(std::make_pair(iItem, pItemInfo)); 273 | } 274 | else 275 | { 276 | ItemMap tmp; 277 | for (it = m_mapItemInfo.begin(); it != itEnd;) 278 | { 279 | if (it->first >= iItem) 280 | { 281 | PITEM_INFO pItem = it->second; 282 | int iIndex = it->first+1; 283 | m_mapItemInfo.erase(it++); 284 | tmp.insert(std::make_pair(iIndex, pItem)); 285 | } 286 | else 287 | { 288 | ++it; 289 | } 290 | } 291 | std::for_each(tmp.begin(), tmp.end(), [&](ItemMap::reference ref) 292 | { 293 | m_mapItemInfo.insert(ref); 294 | }); 295 | m_mapItemInfo.insert(std::make_pair(iItem, pItemInfo)); 296 | } 297 | 298 | return CListCtrl::InsertItem(iItem, lpszItem); 299 | } 300 | 301 | 302 | int CTBListCtrl::InsertItem(int iItem, PITEM_INFO pItemInfo) 303 | { 304 | if (iItem > GetItemCount()) 305 | { 306 | return -1; 307 | } 308 | ItemMap::iterator it = m_mapItemInfo.find(iItem); 309 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 310 | if(it == itEnd) 311 | { 312 | m_mapItemInfo.insert(std::make_pair(iItem, pItemInfo)); 313 | } 314 | else 315 | { 316 | ItemMap tmp; 317 | for (it = m_mapItemInfo.begin(); it != itEnd;) 318 | { 319 | if (it->first >= iItem) 320 | { 321 | PITEM_INFO pItem = it->second; 322 | int iIndex = it->first+1; 323 | m_mapItemInfo.erase(it++); 324 | tmp.insert(std::make_pair(iIndex, pItem)); 325 | } 326 | else 327 | { 328 | ++it; 329 | } 330 | } 331 | std::for_each(tmp.begin(), tmp.end(), [&](ItemMap::reference ref) 332 | { 333 | m_mapItemInfo.insert(ref); 334 | }); 335 | m_mapItemInfo.insert(std::make_pair(iItem, pItemInfo)); 336 | } 337 | return CListCtrl::InsertItem(iItem, pItemInfo->listSubItem.front().strNormal); 338 | } 339 | 340 | 341 | BOOL CTBListCtrl::SetItemBkColor(int iItem, COLORREF clrBkColor) 342 | { 343 | ItemMap::iterator it = m_mapItemInfo.find(iItem); 344 | if (m_mapItemInfo.end() == it) 345 | { 346 | PITEM_INFO itemInfo = new ITEM_INFO; 347 | itemInfo->clrBkColor = clrBkColor; 348 | //itemInfo->dwFlags = LISTITEM_NORMAL; 349 | m_mapItemInfo.insert(std::make_pair(iItem, itemInfo)); 350 | return FALSE; 351 | } 352 | else 353 | { 354 | it->second->clrBkColor = clrBkColor; 355 | return TRUE; 356 | } 357 | } 358 | 359 | 360 | void CTBListCtrl::SetRowHeight(int iItemHeight/* = 0x20*/) 361 | { 362 | m_dwRowHeight = static_cast(iItemHeight); 363 | 364 | CRect rcWin; 365 | GetWindowRect(&rcWin); 366 | WINDOWPOS wp; 367 | wp.hwnd = m_hWnd; 368 | wp.cx = rcWin.Width(); 369 | wp.cy = rcWin.Height(); 370 | wp.flags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER; 371 | SendMessage(WM_WINDOWPOSCHANGED, static_cast(0), reinterpret_cast(&wp)); 372 | } 373 | 374 | //void CTBListCtrl::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) 375 | //{ 376 | // lpMeasureItemStruct->itemHeight = m_dwRowHeight; 377 | // 378 | // CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct); 379 | //} 380 | 381 | void CTBListCtrl::MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct ) 382 | { 383 | if (m_dwRowHeight > 0) 384 | { 385 | lpMeasureItemStruct->itemHeight = m_dwRowHeight; 386 | } 387 | } 388 | 389 | 390 | BOOL CTBListCtrl::SetItemTextColor(int iItem, int iSubItem, COLORREF clrColor) 391 | { 392 | map::iterator it = m_mapItemInfo.find(iItem); 393 | if (m_mapItemInfo.end() == it) 394 | { 395 | PITEM_INFO pItemInfo = new ITEM_INFO; 396 | pItemInfo->clrBkColor = DEFAULT_NORMAL_BK_COLOR; 397 | pItemInfo->clrNormalColor = DEFAULT_NORMAL_TEXT_COLOR; 398 | 399 | SUBITEM_INFO subItemInfo; 400 | subItemInfo.clrTextColor = clrColor; 401 | subItemInfo.iSubItem = iSubItem; 402 | subItemInfo.pBtn = NULL; 403 | pItemInfo->listSubItem.push_back(subItemInfo); 404 | m_mapItemInfo.insert(std::make_pair(iItem, pItemInfo)); 405 | return FALSE; 406 | } 407 | else 408 | { 409 | list::iterator subIt = it->second->listSubItem.begin(); 410 | list::iterator subItEnd = it->second->listSubItem.end(); 411 | for (; subIt != subItEnd; ++subIt) 412 | { 413 | if (iSubItem == subIt->iSubItem) 414 | { 415 | subIt->clrTextColor = clrColor; 416 | return TRUE; 417 | } 418 | } 419 | SUBITEM_INFO subItemInfo; 420 | subItemInfo.clrTextColor = clrColor; 421 | subItemInfo.iSubItem = iSubItem; 422 | subItemInfo.pBtn = NULL; 423 | it->second->listSubItem.push_back(subItemInfo); 424 | return TRUE; 425 | } 426 | } 427 | 428 | 429 | BOOL CTBListCtrl::SetItemText(_In_ int nItem, _In_ int nSubItem, _In_z_ LPCTSTR lpszText, COLORREF clrTextColor /* = DEFAULT_NORMAL_TEXT_COLOR */) 430 | { 431 | if (nSubItem >= GetHeaderCtrl()->GetItemCount()) 432 | { 433 | return FALSE; 434 | } 435 | 436 | ItemMap::iterator itItem = m_mapItemInfo.find(nItem); 437 | if (m_mapItemInfo.end() != itItem) 438 | { 439 | list::iterator itSub, itSubEnd; 440 | itSub = itItem->second->listSubItem.begin(); 441 | itSubEnd = itItem->second->listSubItem.end(); 442 | 443 | for (; itSub != itSubEnd; ++itSub) 444 | { 445 | if (itSub->iSubItem == nSubItem) 446 | { 447 | itSub->strNormal = lpszText; 448 | if (DEFAULT_NORMAL_TEXT_COLOR != clrTextColor) 449 | { 450 | SetItemTextColor(nItem, nSubItem, clrTextColor); 451 | } 452 | return CListCtrl::SetItemText(nItem, nSubItem, lpszText); 453 | } 454 | } 455 | 456 | SUBITEM_INFO subItemInfo; 457 | subItemInfo.clrBkColor = DEFAULT_NORMAL_BK_COLOR; 458 | subItemInfo.clrTextColor = clrTextColor; 459 | subItemInfo.iSubItem = nSubItem; 460 | subItemInfo.pBtn = NULL; 461 | subItemInfo.strNormal = lpszText; 462 | itItem->second->listSubItem.push_back(subItemInfo); 463 | return CListCtrl::SetItemText(nItem, nSubItem, lpszText); 464 | } 465 | else 466 | { 467 | return FALSE; 468 | } 469 | } 470 | 471 | 472 | void CTBListCtrl::OnDestroy() 473 | { 474 | CListCtrl::OnDestroy(); 475 | 476 | ClearMapInfo(); 477 | if (m_hHook) 478 | { 479 | VERIFY(::UnhookWindowsHookEx(m_hHook)); 480 | } 481 | } 482 | 483 | 484 | void CTBListCtrl::ClearMapInfo() 485 | { 486 | std::for_each(m_mapItemInfo.begin(), m_mapItemInfo.end(), 487 | [](ItemMap::reference item) 488 | { 489 | std::for_each(item.second->listSubItem.begin(), item.second->listSubItem.end(), 490 | [](list::reference subItem) 491 | { 492 | if (subItem.pBtn) 493 | { 494 | subItem.pBtn->DestroyWindow(); 495 | delete subItem.pBtn; 496 | } 497 | }); 498 | delete item.second; 499 | }); 500 | m_mapItemInfo.clear(); 501 | } 502 | 503 | 504 | BOOL CTBListCtrl::DeleteItem(_In_ int nItem) 505 | { 506 | if (nItem >= GetItemCount()) 507 | { 508 | return FALSE; 509 | } 510 | ItemMap::iterator it = m_mapItemInfo.find(nItem); 511 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 512 | if(it != itEnd) 513 | { 514 | delete it->second; 515 | m_mapItemInfo.erase(it); 516 | } 517 | 518 | ItemMap tmp; 519 | for (it = m_mapItemInfo.begin(); it != itEnd;) 520 | { 521 | if (it->first > nItem) 522 | { 523 | PITEM_INFO pItem = it->second; 524 | int iIndex = it->first-1; 525 | m_mapItemInfo.erase(it++); 526 | tmp.insert(std::make_pair(iIndex, pItem)); 527 | } 528 | else 529 | { 530 | ++it; 531 | } 532 | } 533 | std::for_each(tmp.begin(), tmp.end(), [&](ItemMap::reference ref) 534 | { 535 | m_mapItemInfo.insert(ref); 536 | }); 537 | //DeleteSelectedItem(nItem); 538 | UpdateComponentPos(); 539 | return CListCtrl::DeleteItem(nItem); 540 | } 541 | 542 | 543 | BOOL CTBListCtrl::DeleteColumn(_In_ int nCol) 544 | { 545 | int iCount = GetHeaderCtrl()->GetItemCount(); 546 | if (nCol >= iCount || 1 == iCount) 547 | { 548 | return FALSE; 549 | } 550 | list::iterator itSub, itSubDel, itSubEnd; 551 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 552 | for (ItemMap::iterator it = m_mapItemInfo.begin(); it != itEnd; ++it) 553 | { 554 | itSub = it->second->listSubItem.begin(); 555 | itSubEnd = it->second->listSubItem.end(); 556 | itSubDel = itSubEnd; 557 | for (; itSub != itSubEnd; ++itSub) 558 | { 559 | if (itSub->iSubItem == nCol) 560 | { 561 | itSubDel = itSub; 562 | } 563 | else if (itSub->iSubItem > nCol) 564 | { 565 | --itSub->iSubItem; 566 | } 567 | } 568 | if (itSubDel != itSubEnd) 569 | { 570 | if (itSubDel->pBtn) 571 | { 572 | itSubDel->pBtn->DestroyWindow(); 573 | delete itSubDel->pBtn; 574 | } 575 | it->second->listSubItem.erase(itSubDel); 576 | } 577 | } 578 | UpdateComponentPos(); 579 | return CListCtrl::DeleteColumn(nCol); 580 | } 581 | 582 | 583 | BOOL CTBListCtrl::DeleteAllItems() 584 | { 585 | ClearMapInfo(); 586 | m_vecSelectedItem.clear(); 587 | return CListCtrl::DeleteAllItems(); 588 | } 589 | 590 | 591 | void CTBListCtrl::InvalidAndUpdateWindow() 592 | { 593 | if (::IsWindow(m_hWnd)) 594 | { 595 | RECT rc; 596 | GetClientRect(&rc); 597 | InvalidateRect(&rc); 598 | UpdateWindow(); 599 | m_headerCtrl.Invalidate(FALSE); 600 | } 601 | } 602 | 603 | 604 | void CTBListCtrl::InvalidAndUpdateItem(int iItem) 605 | { 606 | if (::IsWindow(m_hWnd) && iItem < GetItemCount()) 607 | { 608 | RECT rect; 609 | if (CListCtrl::GetItemRect(iItem, &rect, LVIR_BOUNDS)) 610 | { 611 | InvalidateRect(&rect); 612 | UpdateWindow(); 613 | } 614 | } 615 | } 616 | 617 | 618 | void CTBListCtrl::SetLineColor(COLORREF clrLineColor) 619 | { 620 | m_clrLineColor = clrLineColor; 621 | } 622 | 623 | 624 | void CTBListCtrl::SetSelectedRowColor(COLORREF clrRow) 625 | { 626 | m_clrSelectedRowColor = clrRow; 627 | } 628 | 629 | BOOL CTBListCtrl::OnEraseBkgnd(CDC* pDC) 630 | { 631 | // TODO: Add your message handler code here and/or call default 632 | //CListCtrl::OnEraseBkgnd(pDC); 633 | CRect rectErase; 634 | GetUpdateRect(&rectErase); 635 | CBrush brush(DEFAULT_NORMAL_BK_COLOR); 636 | pDC->FillRect(&rectErase, &brush); 637 | //m_headerCtrl.DrawHeader(pDC); 638 | return TRUE; 639 | //return CListCtrl::OnEraseBkgnd(pDC); 640 | } 641 | 642 | 643 | BOOL CTBListCtrl::InitListCtrl() 644 | { 645 | /*m_hHook = ::SetWindowsHookEx(WH_CBT, CBTProc, NULL, 646 | ::GetWindowThreadProcessId(GetParent()->GetSafeHwnd(), NULL)); 647 | ASSERT(m_hHook); 648 | return NULL != m_hHook;*/ 649 | LONG lStyle = GetWindowLong(GetSafeHwnd(), GWL_STYLE); 650 | lStyle |= (LVS_REPORT|WS_CLIPCHILDREN|LVS_OWNERDRAWFIXED); 651 | SetWindowLong(GetSafeHwnd(), GWL_STYLE, lStyle); 652 | 653 | LONG lExStyle = GetExtendedStyle(); 654 | lExStyle |= (LVS_EX_DOUBLEBUFFER|LVS_EX_TRANSPARENTBKGND); 655 | lExStyle &= (~LVS_EX_GRIDLINES); 656 | SetExtendedStyle(lExStyle); 657 | 658 | m_headerCtrl.SetListCtrl(this); 659 | return TRUE; 660 | } 661 | 662 | 663 | LRESULT CALLBACK CTBListCtrl::CBTProc(int code,WPARAM wParam,LPARAM lParam) 664 | { 665 | if (HCBT_MOVESIZE == code) 666 | { 667 | if (::IsWindowEnabled(m_pWnd->GetSafeHwnd())) 668 | { 669 | CRect rcClient, rcParentClient; 670 | m_pWnd->GetParent()->GetClientRect(&rcParentClient); 671 | /*m_pWnd->GetWindowRect(&rcClient); 672 | m_pWnd->GetParent()->ScreenToClient(&rcClient);*/ 673 | rcClient.top = 11; 674 | rcClient.left = 44; 675 | rcClient.right = rcParentClient.right - 48; 676 | rcClient.bottom = rcParentClient.bottom - 50; 677 | m_pWnd->MoveWindow(rcClient); 678 | 679 | } 680 | 681 | } 682 | else if (HCBT_MINMAX == code) 683 | { 684 | WORD wFlag = LOWORD(lParam); 685 | if (SW_MAXIMIZE == wFlag) 686 | { 687 | CRect rcParentClient, rcClient; 688 | VERIFY(::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcParentClient, 0)); 689 | rcClient.top = 11; 690 | rcClient.left = 44; 691 | rcClient.right = rcParentClient.right - 48; 692 | rcClient.bottom = rcParentClient.bottom - 50; 693 | m_pWnd->MoveWindow(rcClient); 694 | } 695 | } 696 | return ::CallNextHookEx(m_hHook, code, wParam, lParam); 697 | } 698 | 699 | 700 | void CTBListCtrl::SetFontWidthHeight(DWORD dwWidth, DWORD dwHeight) 701 | { 702 | m_dwFontWidth = dwWidth; 703 | m_dwFontHeight = dwHeight; 704 | } 705 | 706 | void CTBListCtrl::SetHeaderHeightRatio(float fRatio) 707 | { 708 | m_headerCtrl.m_Height = fRatio; 709 | } 710 | 711 | 712 | void CTBListCtrl::SetHeaderBkColor(int R, int G, int B, int iGradient) 713 | { 714 | m_headerCtrl.m_R = R; 715 | m_headerCtrl.m_G = G; 716 | m_headerCtrl.m_B = B; 717 | m_headerCtrl.m_Gradient = iGradient; 718 | } 719 | 720 | void CTBListCtrl::SetHeaderBkColor(COLORREF clrBk, int iGradient) 721 | { 722 | m_headerCtrl.m_Gradient = iGradient; 723 | m_headerCtrl.m_R = GetRValue(clrBk); 724 | m_headerCtrl.m_G = GetGValue(clrBk); 725 | m_headerCtrl.m_B = GetBValue(clrBk); 726 | } 727 | 728 | 729 | void CTBListCtrl::SetHeaderFontWithHeight(int iWidth, int iHeight) 730 | { 731 | m_headerCtrl.m_fontWith = iWidth; 732 | m_headerCtrl.m_fontHeight = iHeight; 733 | } 734 | 735 | 736 | void CTBListCtrl::PreSubclassWindow() 737 | { 738 | // TODO: Add your specialized code here and/or call the base class 739 | 740 | CHeaderCtrl* pHeader = GetHeaderCtrl(); 741 | if (pHeader) 742 | { 743 | VERIFY(m_headerCtrl.SubclassWindow(pHeader->m_hWnd)); 744 | } 745 | CListCtrl::PreSubclassWindow(); 746 | } 747 | 748 | 749 | BOOL CTBListCtrl::SetItemButton(int iItem, int iSubItem, CButton* pBtn, int nID, DWORD dwStyle, 750 | LPCTSTR lpszCaption) 751 | { 752 | map::iterator it = m_mapItemInfo.find(iItem); 753 | if (m_mapItemInfo.end() == it) 754 | { 755 | return FALSE; 756 | } 757 | else 758 | { 759 | list::iterator subIt = it->second->listSubItem.begin(); 760 | list::iterator subItEnd = it->second->listSubItem.end(); 761 | CRect rect; 762 | VERIFY(GetSubItemRect(iItem, iSubItem, LVIR_LABEL, rect)); 763 | rect.DeflateRect(CSize(1, 1)); 764 | for (; subIt != subItEnd; ++subIt) 765 | { 766 | if (iSubItem == subIt->iSubItem) 767 | { 768 | ASSERT(pBtn); 769 | if (subIt->pBtn) 770 | { 771 | subIt->pBtn->DestroyWindow(); 772 | delete subIt->pBtn; 773 | } 774 | subIt->pBtn = pBtn; 775 | pBtn->Create(lpszCaption, dwStyle|WS_CHILD|WS_CLIPCHILDREN, rect, this, nID); 776 | return TRUE; 777 | } 778 | } 779 | SUBITEM_INFO subItemInfo; 780 | subItemInfo.iSubItem = iSubItem; 781 | ASSERT(pBtn); 782 | subItemInfo.pBtn = pBtn; 783 | pBtn->Create(lpszCaption, dwStyle|WS_CHILD|WS_CLIPCHILDREN, rect, this, nID); 784 | it->second->listSubItem.push_back(subItemInfo); 785 | return TRUE; 786 | } 787 | } 788 | 789 | 790 | CButton* CTBListCtrl::GetItemButton(int iItem, int iSubItem) 791 | { 792 | ItemMap::iterator itFind = m_mapItemInfo.find(iItem); 793 | if (m_mapItemInfo.end() == itFind) 794 | { 795 | return NULL; 796 | } 797 | else 798 | { 799 | list::iterator subIt = itFind->second->listSubItem.begin(); 800 | list::iterator subItEnd = itFind->second->listSubItem.end(); 801 | list::iterator itItem = std::find_if(subIt, subItEnd, 802 | [iSubItem](list::reference subItem) 803 | { 804 | return subItem.iSubItem == iSubItem; 805 | }); 806 | if (subItEnd == itItem) 807 | { 808 | return NULL; 809 | } 810 | else 811 | { 812 | return itItem->pBtn; 813 | } 814 | } 815 | } 816 | 817 | 818 | void CTBListCtrl::UpdateComponentPos(BOOL bRepaint) 819 | { 820 | ItemMap::iterator it = m_mapItemInfo.begin(); 821 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 822 | 823 | list::iterator itSub, itSubEnd; 824 | CRect subItemRect; 825 | 826 | while (it != itEnd) 827 | { 828 | itSub = it->second->listSubItem.begin(); 829 | itSubEnd = it->second->listSubItem.end(); 830 | while (itSub != itSubEnd) 831 | { 832 | if (itSub->pBtn) 833 | { 834 | VERIFY(GetSubItemRect(it->first, itSub->iSubItem, LVIR_LABEL, subItemRect)); 835 | subItemRect.DeflateRect(CSize(1, 1)); 836 | 837 | if (!IsItemVisible(it->first)) 838 | { 839 | itSub->pBtn->EnableWindow(FALSE); 840 | itSub->pBtn->ShowWindow(SW_HIDE); 841 | itSub->pBtn->MoveWindow(&subItemRect, bRepaint); 842 | } 843 | else 844 | { 845 | itSub->pBtn->MoveWindow(&subItemRect, bRepaint); 846 | itSub->pBtn->EnableWindow(TRUE); 847 | itSub->pBtn->ShowWindow(SW_SHOW); 848 | } 849 | ::SendMessage(itSub->pBtn->m_hWnd, UM_MOVE_COMPONENT, it->first, itSub->iSubItem); 850 | itSub->pBtn->Invalidate(TRUE); 851 | } 852 | ++itSub; 853 | } 854 | ++it; 855 | } 856 | } 857 | 858 | 859 | //void CTBListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 860 | //{ 861 | // CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar); 862 | // UpdateComponentPos(); 863 | // InvalidAndUpdateWindow(); 864 | // 865 | //} 866 | // 867 | // 868 | //void CTBListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 869 | //{ 870 | // CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar); 871 | // UpdateComponentPos(); 872 | // InvalidAndUpdateWindow(); 873 | //} 874 | 875 | 876 | BOOL CTBListCtrl::OnNMClick(NMHDR * pNotifyStruct, LRESULT* result) 877 | { 878 | LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE)pNotifyStruct; 879 | ASSERT(lpnmitem); 880 | 881 | /*LVHITTESTINFO info; 882 | info.pt = lpnmitem->ptAction; 883 | info.flags = LVHT_ONITEM; 884 | info.iItem = lpnmitem->iItem; 885 | info.iSubItem = lpnmitem->iSubItem; 886 | info.iGroup = 0; 887 | int iIndex = SubItemHitTest(&info);*/ 888 | int iIndex = lpnmitem->iItem; 889 | if (-1 != iIndex) 890 | { 891 | if (!(m_dwExStyle & LVS_EX_FULLROWSELECT)) 892 | { 893 | if (0 != lpnmitem->iSubItem) 894 | { 895 | return FALSE; 896 | } 897 | } 898 | 899 | ItemMap::iterator itItem = m_mapItemInfo.find(iIndex); 900 | if (m_mapItemInfo.end() != itItem) 901 | { 902 | itItem->second->bSelected = !itItem->second->bSelected; 903 | /*if (itItem->second->bSelected) 904 | { 905 | m_vecSelectedItem.push_back(iIndex); 906 | } 907 | else 908 | { 909 | DeleteSelectedItem(iIndex); 910 | }*/ 911 | 912 | InvalidAndUpdateItem(iIndex); 913 | } 914 | else 915 | { 916 | AfxDebugBreak(); 917 | } 918 | } 919 | else 920 | { 921 | //AfxDebugBreak(); 922 | } 923 | *result = 0; 924 | return FALSE; 925 | } 926 | 927 | 928 | //void CTBListCtrl::OnNMCustomDraw(NMHDR * pNotifyStruct, LRESULT* result) 929 | //{ 930 | // LPNMLVCUSTOMDRAW lpNMCustomDraw = (LPNMLVCUSTOMDRAW)pNotifyStruct; 931 | // *result = CDRF_DODEFAULT; 932 | // switch (lpNMCustomDraw->nmcd.dwDrawStage) 933 | // { 934 | // case CDDS_PREPAINT: 935 | // *result = CDRF_NOTIFYITEMDRAW; 936 | // break; 937 | // case CDDS_ITEMPREPAINT: 938 | // *result = CDRF_NOTIFYSUBITEMDRAW; 939 | // break; 940 | // case CDDS_SUBITEM|CDDS_ITEMPREPAINT: 941 | // { 942 | // UpdateComponentPos(); 943 | // m_headerCtrl.DrawHeader(CDC::FromHandle(lpNMCustomDraw->nmcd.hdc)); 944 | // *result=CDRF_SKIPDEFAULT; 945 | // } 946 | // break; 947 | // default: 948 | // break; 949 | // } 950 | // //if (CDDS_PREPAINT == lpNMCustomDraw->nmcd.dwDrawStage) 951 | // //{ 952 | // // UpdateComponentPos(); 953 | // // //CWnd::FromHandle(lpNMCustomDraw->nmcd.hdr.hwndFrom)->Invalidate(TRUE); 954 | // // *result = CDRF_NOTIFYITEMDRAW; 955 | // //} 956 | // //return FALSE; 957 | //} 958 | 959 | 960 | LRESULT CTBListCtrl::OnBnClickedCallBack(WPARAM wParam, LPARAM lParam) 961 | { 962 | return ::SendMessage(GetParent()->m_hWnd, BN_CLICKED, wParam, lParam); 963 | } 964 | 965 | 966 | void CTBListCtrl::OnPaint() 967 | { 968 | Default(); 969 | if (GetItemCount() <= 0) 970 | { 971 | CDC* pDC = GetDC(); 972 | int iSaveDC = pDC->SaveDC(); 973 | CRect rc; 974 | GetWindowRect(&rc); 975 | ScreenToClient(&rc); 976 | CRect rcHead; 977 | ASSERT_VALID(&m_headerCtrl); 978 | m_headerCtrl.GetItemRect(0, &rcHead); 979 | rc.top += rcHead.bottom; 980 | //rc.bottom += 10; 981 | CBrush brush(DEFAULT_NORMAL_BK_COLOR); 982 | pDC->FillRect(&rc, &brush); 983 | pDC->RestoreDC(iSaveDC); 984 | ReleaseDC(pDC); 985 | m_headerCtrl.DrawHeader(); 986 | } 987 | } 988 | 989 | 990 | BOOL CTBListCtrl::GetCheck(int iItem) const 991 | { 992 | ItemMap::const_iterator itItem = m_mapItemInfo.find(iItem); 993 | if (m_mapItemInfo.end() == itItem) 994 | { 995 | return FALSE; 996 | } 997 | else 998 | { 999 | return (BOOL)itItem->second->bSelected; 1000 | } 1001 | } 1002 | 1003 | 1004 | //void CTBListCtrl::DeleteSelectedItem(int iIndex) 1005 | //{ 1006 | // m_vecSelectedItem.erase( 1007 | // std::remove_if(m_vecSelectedItem.begin(), m_vecSelectedItem.end(), 1008 | // [iIndex](vector::reference ref) -> bool 1009 | // { 1010 | // return ref == iIndex; 1011 | // }), m_vecSelectedItem.end()); 1012 | //} 1013 | 1014 | 1015 | const vector& CTBListCtrl::GetSelectedItems() 1016 | { 1017 | int iItemCount = GetItemCount(); 1018 | m_vecSelectedItem.clear(); 1019 | for (int i = 0; i < iItemCount; ++i) 1020 | { 1021 | if (GetCheck(i)) 1022 | { 1023 | m_vecSelectedItem.push_back(i); 1024 | } 1025 | } 1026 | return m_vecSelectedItem; 1027 | } 1028 | 1029 | 1030 | BOOL CTBListCtrl::SetCheck(_In_ int nItem, _In_ BOOL fCheck /* = TRUE */) 1031 | { 1032 | ItemMap::iterator itItem = m_mapItemInfo.find(nItem); 1033 | if (m_mapItemInfo.end() == itItem) 1034 | { 1035 | return FALSE; 1036 | } 1037 | itItem->second->bSelected = fCheck ? true : false; 1038 | /*DeleteSelectedItem(nItem); 1039 | if (fCheck) 1040 | { 1041 | m_vecSelectedItem.push_back(nItem); 1042 | }*/ 1043 | return TRUE; 1044 | } 1045 | 1046 | 1047 | BOOL CTBListCtrl::MoveItem(int iItemFrom, int iItemTo) 1048 | { 1049 | ItemMap::iterator it = m_mapItemInfo.find(iItemFrom); 1050 | ItemMap::iterator itEnd = m_mapItemInfo.end(); 1051 | if (itEnd == it) 1052 | { 1053 | return FALSE; 1054 | } 1055 | 1056 | // store ITEM_INFO 1057 | PITEM_INFO pFrom = it->second; 1058 | 1059 | // delete row from list view but not delete ITEM_INFO 1060 | m_mapItemInfo.erase(it); 1061 | ItemMap tmp; 1062 | for (it = m_mapItemInfo.begin(); it != itEnd;) 1063 | { 1064 | if (it->first > iItemFrom) 1065 | { 1066 | PITEM_INFO pItem = it->second; 1067 | int iIndex = it->first-1; 1068 | m_mapItemInfo.erase(it++); 1069 | tmp.insert(std::make_pair(iIndex, pItem)); 1070 | } 1071 | else 1072 | { 1073 | ++it; 1074 | } 1075 | } 1076 | std::for_each(tmp.begin(), tmp.end(), [&](ItemMap::reference ref) 1077 | { 1078 | m_mapItemInfo.insert(ref); 1079 | }); 1080 | VERIFY(__super::DeleteItem(iItemFrom)); 1081 | int iItem = InsertItem(iItemTo, pFrom); 1082 | if (-1 == iItem) 1083 | { 1084 | return FALSE; 1085 | } 1086 | else 1087 | { 1088 | UpdateComponentPos(); 1089 | return TRUE; 1090 | } 1091 | //return -1 == InsertItem(iItemTo, pFrom) ? FALSE : TRUE; 1092 | } 1093 | 1094 | 1095 | BOOL CTBListCtrl::OnLvnEndScroll( NMHDR * pNotifyStruct, LRESULT* result) 1096 | { 1097 | UpdateComponentPos(); 1098 | InvalidAndUpdateWindow(); 1099 | return FALSE; 1100 | } 1101 | 1102 | 1103 | DWORD CTBListCtrl::SetExtendedStyle(DWORD dwNewStyle) 1104 | { 1105 | DWORD dwPreStyle = __super::SetExtendedStyle(dwNewStyle); 1106 | m_dwExStyle = dwPreStyle | dwNewStyle; 1107 | return dwPreStyle; 1108 | } 1109 | 1110 | 1111 | CString CTBListCtrl::GetItemText(_In_ int nItem, _In_ int nSubItem) 1112 | { 1113 | ItemMap::iterator itFind = m_mapItemInfo.find(nItem); 1114 | if (m_mapItemInfo.end() != itFind) 1115 | { 1116 | list::iterator itSubFind = std::find_if(itFind->second->listSubItem.begin(), 1117 | itFind->second->listSubItem.end(), 1118 | [nSubItem](list::reference ref)->bool 1119 | { 1120 | return ref.iSubItem == nSubItem; 1121 | }); 1122 | if (itFind->second->listSubItem.end() != itSubFind) 1123 | { 1124 | return itSubFind->strNormal; 1125 | } 1126 | } 1127 | return _T(""); 1128 | } -------------------------------------------------------------------------------- /12306Client_MFC/include/curl/typecheck-gcc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_TYPECHECK_GCC_H 2 | #define __CURL_TYPECHECK_GCC_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, 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 http://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 | /* wraps curl_easy_setopt() with typechecking */ 26 | 27 | /* To add a new kind of warning, add an 28 | * if(_curl_is_sometype_option(_curl_opt)) 29 | * if(!_curl_is_sometype(value)) 30 | * _curl_easy_setopt_err_sometype(); 31 | * block and define _curl_is_sometype_option, _curl_is_sometype and 32 | * _curl_easy_setopt_err_sometype below 33 | * 34 | * NOTE: We use two nested 'if' statements here instead of the && operator, in 35 | * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x 36 | * when compiling with -Wlogical-op. 37 | * 38 | * To add an option that uses the same type as an existing option, you'll just 39 | * need to extend the appropriate _curl_*_option macro 40 | */ 41 | #define curl_easy_setopt(handle, option, value) \ 42 | __extension__ ({ \ 43 | __typeof__ (option) _curl_opt = option; \ 44 | if(__builtin_constant_p(_curl_opt)) { \ 45 | if(_curl_is_long_option(_curl_opt)) \ 46 | if(!_curl_is_long(value)) \ 47 | _curl_easy_setopt_err_long(); \ 48 | if(_curl_is_off_t_option(_curl_opt)) \ 49 | if(!_curl_is_off_t(value)) \ 50 | _curl_easy_setopt_err_curl_off_t(); \ 51 | if(_curl_is_string_option(_curl_opt)) \ 52 | if(!_curl_is_string(value)) \ 53 | _curl_easy_setopt_err_string(); \ 54 | if(_curl_is_write_cb_option(_curl_opt)) \ 55 | if(!_curl_is_write_cb(value)) \ 56 | _curl_easy_setopt_err_write_callback(); \ 57 | if((_curl_opt) == CURLOPT_READFUNCTION) \ 58 | if(!_curl_is_read_cb(value)) \ 59 | _curl_easy_setopt_err_read_cb(); \ 60 | if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \ 61 | if(!_curl_is_ioctl_cb(value)) \ 62 | _curl_easy_setopt_err_ioctl_cb(); \ 63 | if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \ 64 | if(!_curl_is_sockopt_cb(value)) \ 65 | _curl_easy_setopt_err_sockopt_cb(); \ 66 | if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \ 67 | if(!_curl_is_opensocket_cb(value)) \ 68 | _curl_easy_setopt_err_opensocket_cb(); \ 69 | if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \ 70 | if(!_curl_is_progress_cb(value)) \ 71 | _curl_easy_setopt_err_progress_cb(); \ 72 | if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \ 73 | if(!_curl_is_debug_cb(value)) \ 74 | _curl_easy_setopt_err_debug_cb(); \ 75 | if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \ 76 | if(!_curl_is_ssl_ctx_cb(value)) \ 77 | _curl_easy_setopt_err_ssl_ctx_cb(); \ 78 | if(_curl_is_conv_cb_option(_curl_opt)) \ 79 | if(!_curl_is_conv_cb(value)) \ 80 | _curl_easy_setopt_err_conv_cb(); \ 81 | if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ 82 | if(!_curl_is_seek_cb(value)) \ 83 | _curl_easy_setopt_err_seek_cb(); \ 84 | if(_curl_is_cb_data_option(_curl_opt)) \ 85 | if(!_curl_is_cb_data(value)) \ 86 | _curl_easy_setopt_err_cb_data(); \ 87 | if((_curl_opt) == CURLOPT_ERRORBUFFER) \ 88 | if(!_curl_is_error_buffer(value)) \ 89 | _curl_easy_setopt_err_error_buffer(); \ 90 | if((_curl_opt) == CURLOPT_STDERR) \ 91 | if(!_curl_is_FILE(value)) \ 92 | _curl_easy_setopt_err_FILE(); \ 93 | if(_curl_is_postfields_option(_curl_opt)) \ 94 | if(!_curl_is_postfields(value)) \ 95 | _curl_easy_setopt_err_postfields(); \ 96 | if((_curl_opt) == CURLOPT_HTTPPOST) \ 97 | if(!_curl_is_arr((value), struct curl_httppost)) \ 98 | _curl_easy_setopt_err_curl_httpost(); \ 99 | if(_curl_is_slist_option(_curl_opt)) \ 100 | if(!_curl_is_arr((value), struct curl_slist)) \ 101 | _curl_easy_setopt_err_curl_slist(); \ 102 | if((_curl_opt) == CURLOPT_SHARE) \ 103 | if(!_curl_is_ptr((value), CURLSH)) \ 104 | _curl_easy_setopt_err_CURLSH(); \ 105 | } \ 106 | curl_easy_setopt(handle, _curl_opt, value); \ 107 | }) 108 | 109 | /* wraps curl_easy_getinfo() with typechecking */ 110 | /* FIXME: don't allow const pointers */ 111 | #define curl_easy_getinfo(handle, info, arg) \ 112 | __extension__ ({ \ 113 | __typeof__ (info) _curl_info = info; \ 114 | if(__builtin_constant_p(_curl_info)) { \ 115 | if(_curl_is_string_info(_curl_info)) \ 116 | if(!_curl_is_arr((arg), char *)) \ 117 | _curl_easy_getinfo_err_string(); \ 118 | if(_curl_is_long_info(_curl_info)) \ 119 | if(!_curl_is_arr((arg), long)) \ 120 | _curl_easy_getinfo_err_long(); \ 121 | if(_curl_is_double_info(_curl_info)) \ 122 | if(!_curl_is_arr((arg), double)) \ 123 | _curl_easy_getinfo_err_double(); \ 124 | if(_curl_is_slist_info(_curl_info)) \ 125 | if(!_curl_is_arr((arg), struct curl_slist *)) \ 126 | _curl_easy_getinfo_err_curl_slist(); \ 127 | } \ 128 | curl_easy_getinfo(handle, _curl_info, arg); \ 129 | }) 130 | 131 | /* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(), 132 | * for now just make sure that the functions are called with three 133 | * arguments 134 | */ 135 | #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) 136 | #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) 137 | 138 | 139 | /* the actual warnings, triggered by calling the _curl_easy_setopt_err* 140 | * functions */ 141 | 142 | /* To define a new warning, use _CURL_WARNING(identifier, "message") */ 143 | #define _CURL_WARNING(id, message) \ 144 | static void __attribute__((__warning__(message))) \ 145 | __attribute__((__unused__)) __attribute__((__noinline__)) \ 146 | id(void) { __asm__(""); } 147 | 148 | _CURL_WARNING(_curl_easy_setopt_err_long, 149 | "curl_easy_setopt expects a long argument for this option") 150 | _CURL_WARNING(_curl_easy_setopt_err_curl_off_t, 151 | "curl_easy_setopt expects a curl_off_t argument for this option") 152 | _CURL_WARNING(_curl_easy_setopt_err_string, 153 | "curl_easy_setopt expects a " 154 | "string (char* or char[]) argument for this option" 155 | ) 156 | _CURL_WARNING(_curl_easy_setopt_err_write_callback, 157 | "curl_easy_setopt expects a curl_write_callback argument for this option") 158 | _CURL_WARNING(_curl_easy_setopt_err_read_cb, 159 | "curl_easy_setopt expects a curl_read_callback argument for this option") 160 | _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb, 161 | "curl_easy_setopt expects a curl_ioctl_callback argument for this option") 162 | _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, 163 | "curl_easy_setopt expects a curl_sockopt_callback argument for this option") 164 | _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, 165 | "curl_easy_setopt expects a " 166 | "curl_opensocket_callback argument for this option" 167 | ) 168 | _CURL_WARNING(_curl_easy_setopt_err_progress_cb, 169 | "curl_easy_setopt expects a curl_progress_callback argument for this option") 170 | _CURL_WARNING(_curl_easy_setopt_err_debug_cb, 171 | "curl_easy_setopt expects a curl_debug_callback argument for this option") 172 | _CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb, 173 | "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option") 174 | _CURL_WARNING(_curl_easy_setopt_err_conv_cb, 175 | "curl_easy_setopt expects a curl_conv_callback argument for this option") 176 | _CURL_WARNING(_curl_easy_setopt_err_seek_cb, 177 | "curl_easy_setopt expects a curl_seek_callback argument for this option") 178 | _CURL_WARNING(_curl_easy_setopt_err_cb_data, 179 | "curl_easy_setopt expects a " 180 | "private data pointer as argument for this option") 181 | _CURL_WARNING(_curl_easy_setopt_err_error_buffer, 182 | "curl_easy_setopt expects a " 183 | "char buffer of CURL_ERROR_SIZE as argument for this option") 184 | _CURL_WARNING(_curl_easy_setopt_err_FILE, 185 | "curl_easy_setopt expects a FILE* argument for this option") 186 | _CURL_WARNING(_curl_easy_setopt_err_postfields, 187 | "curl_easy_setopt expects a void* or char* argument for this option") 188 | _CURL_WARNING(_curl_easy_setopt_err_curl_httpost, 189 | "curl_easy_setopt expects a struct curl_httppost* argument for this option") 190 | _CURL_WARNING(_curl_easy_setopt_err_curl_slist, 191 | "curl_easy_setopt expects a struct curl_slist* argument for this option") 192 | _CURL_WARNING(_curl_easy_setopt_err_CURLSH, 193 | "curl_easy_setopt expects a CURLSH* argument for this option") 194 | 195 | _CURL_WARNING(_curl_easy_getinfo_err_string, 196 | "curl_easy_getinfo expects a pointer to char * for this info") 197 | _CURL_WARNING(_curl_easy_getinfo_err_long, 198 | "curl_easy_getinfo expects a pointer to long for this info") 199 | _CURL_WARNING(_curl_easy_getinfo_err_double, 200 | "curl_easy_getinfo expects a pointer to double for this info") 201 | _CURL_WARNING(_curl_easy_getinfo_err_curl_slist, 202 | "curl_easy_getinfo expects a pointer to struct curl_slist * for this info") 203 | 204 | /* groups of curl_easy_setops options that take the same type of argument */ 205 | 206 | /* To add a new option to one of the groups, just add 207 | * (option) == CURLOPT_SOMETHING 208 | * to the or-expression. If the option takes a long or curl_off_t, you don't 209 | * have to do anything 210 | */ 211 | 212 | /* evaluates to true if option takes a long argument */ 213 | #define _curl_is_long_option(option) \ 214 | (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) 215 | 216 | #define _curl_is_off_t_option(option) \ 217 | ((option) > CURLOPTTYPE_OFF_T) 218 | 219 | /* evaluates to true if option takes a char* argument */ 220 | #define _curl_is_string_option(option) \ 221 | ((option) == CURLOPT_URL || \ 222 | (option) == CURLOPT_PROXY || \ 223 | (option) == CURLOPT_INTERFACE || \ 224 | (option) == CURLOPT_NETRC_FILE || \ 225 | (option) == CURLOPT_USERPWD || \ 226 | (option) == CURLOPT_USERNAME || \ 227 | (option) == CURLOPT_PASSWORD || \ 228 | (option) == CURLOPT_PROXYUSERPWD || \ 229 | (option) == CURLOPT_PROXYUSERNAME || \ 230 | (option) == CURLOPT_PROXYPASSWORD || \ 231 | (option) == CURLOPT_NOPROXY || \ 232 | (option) == CURLOPT_ACCEPT_ENCODING || \ 233 | (option) == CURLOPT_REFERER || \ 234 | (option) == CURLOPT_USERAGENT || \ 235 | (option) == CURLOPT_COOKIE || \ 236 | (option) == CURLOPT_COOKIEFILE || \ 237 | (option) == CURLOPT_COOKIEJAR || \ 238 | (option) == CURLOPT_COOKIELIST || \ 239 | (option) == CURLOPT_FTPPORT || \ 240 | (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ 241 | (option) == CURLOPT_FTP_ACCOUNT || \ 242 | (option) == CURLOPT_RANGE || \ 243 | (option) == CURLOPT_CUSTOMREQUEST || \ 244 | (option) == CURLOPT_SSLCERT || \ 245 | (option) == CURLOPT_SSLCERTTYPE || \ 246 | (option) == CURLOPT_SSLKEY || \ 247 | (option) == CURLOPT_SSLKEYTYPE || \ 248 | (option) == CURLOPT_KEYPASSWD || \ 249 | (option) == CURLOPT_SSLENGINE || \ 250 | (option) == CURLOPT_CAINFO || \ 251 | (option) == CURLOPT_CAPATH || \ 252 | (option) == CURLOPT_RANDOM_FILE || \ 253 | (option) == CURLOPT_EGDSOCKET || \ 254 | (option) == CURLOPT_SSL_CIPHER_LIST || \ 255 | (option) == CURLOPT_KRBLEVEL || \ 256 | (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ 257 | (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ 258 | (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ 259 | (option) == CURLOPT_CRLFILE || \ 260 | (option) == CURLOPT_ISSUERCERT || \ 261 | (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ 262 | (option) == CURLOPT_SSH_KNOWNHOSTS || \ 263 | (option) == CURLOPT_MAIL_FROM || \ 264 | (option) == CURLOPT_RTSP_SESSION_ID || \ 265 | (option) == CURLOPT_RTSP_STREAM_URI || \ 266 | (option) == CURLOPT_RTSP_TRANSPORT || \ 267 | (option) == CURLOPT_XOAUTH2_BEARER || \ 268 | (option) == CURLOPT_DNS_SERVERS || \ 269 | (option) == CURLOPT_DNS_INTERFACE || \ 270 | (option) == CURLOPT_DNS_LOCAL_IP4 || \ 271 | (option) == CURLOPT_DNS_LOCAL_IP6 || \ 272 | (option) == CURLOPT_LOGIN_OPTIONS || \ 273 | 0) 274 | 275 | /* evaluates to true if option takes a curl_write_callback argument */ 276 | #define _curl_is_write_cb_option(option) \ 277 | ((option) == CURLOPT_HEADERFUNCTION || \ 278 | (option) == CURLOPT_WRITEFUNCTION) 279 | 280 | /* evaluates to true if option takes a curl_conv_callback argument */ 281 | #define _curl_is_conv_cb_option(option) \ 282 | ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ 283 | (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ 284 | (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) 285 | 286 | /* evaluates to true if option takes a data argument to pass to a callback */ 287 | #define _curl_is_cb_data_option(option) \ 288 | ((option) == CURLOPT_WRITEDATA || \ 289 | (option) == CURLOPT_READDATA || \ 290 | (option) == CURLOPT_IOCTLDATA || \ 291 | (option) == CURLOPT_SOCKOPTDATA || \ 292 | (option) == CURLOPT_OPENSOCKETDATA || \ 293 | (option) == CURLOPT_PROGRESSDATA || \ 294 | (option) == CURLOPT_WRITEHEADER || \ 295 | (option) == CURLOPT_DEBUGDATA || \ 296 | (option) == CURLOPT_SSL_CTX_DATA || \ 297 | (option) == CURLOPT_SEEKDATA || \ 298 | (option) == CURLOPT_PRIVATE || \ 299 | (option) == CURLOPT_SSH_KEYDATA || \ 300 | (option) == CURLOPT_INTERLEAVEDATA || \ 301 | (option) == CURLOPT_CHUNK_DATA || \ 302 | (option) == CURLOPT_FNMATCH_DATA || \ 303 | 0) 304 | 305 | /* evaluates to true if option takes a POST data argument (void* or char*) */ 306 | #define _curl_is_postfields_option(option) \ 307 | ((option) == CURLOPT_POSTFIELDS || \ 308 | (option) == CURLOPT_COPYPOSTFIELDS || \ 309 | 0) 310 | 311 | /* evaluates to true if option takes a struct curl_slist * argument */ 312 | #define _curl_is_slist_option(option) \ 313 | ((option) == CURLOPT_HTTPHEADER || \ 314 | (option) == CURLOPT_HTTP200ALIASES || \ 315 | (option) == CURLOPT_QUOTE || \ 316 | (option) == CURLOPT_POSTQUOTE || \ 317 | (option) == CURLOPT_PREQUOTE || \ 318 | (option) == CURLOPT_TELNETOPTIONS || \ 319 | (option) == CURLOPT_MAIL_RCPT || \ 320 | 0) 321 | 322 | /* groups of curl_easy_getinfo infos that take the same type of argument */ 323 | 324 | /* evaluates to true if info expects a pointer to char * argument */ 325 | #define _curl_is_string_info(info) \ 326 | (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG) 327 | 328 | /* evaluates to true if info expects a pointer to long argument */ 329 | #define _curl_is_long_info(info) \ 330 | (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) 331 | 332 | /* evaluates to true if info expects a pointer to double argument */ 333 | #define _curl_is_double_info(info) \ 334 | (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) 335 | 336 | /* true if info expects a pointer to struct curl_slist * argument */ 337 | #define _curl_is_slist_info(info) \ 338 | (CURLINFO_SLIST < (info)) 339 | 340 | 341 | /* typecheck helpers -- check whether given expression has requested type*/ 342 | 343 | /* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros, 344 | * otherwise define a new macro. Search for __builtin_types_compatible_p 345 | * in the GCC manual. 346 | * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is 347 | * the actual expression passed to the curl_easy_setopt macro. This 348 | * means that you can only apply the sizeof and __typeof__ operators, no 349 | * == or whatsoever. 350 | */ 351 | 352 | /* XXX: should evaluate to true iff expr is a pointer */ 353 | #define _curl_is_any_ptr(expr) \ 354 | (sizeof(expr) == sizeof(void*)) 355 | 356 | /* evaluates to true if expr is NULL */ 357 | /* XXX: must not evaluate expr, so this check is not accurate */ 358 | #define _curl_is_NULL(expr) \ 359 | (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) 360 | 361 | /* evaluates to true if expr is type*, const type* or NULL */ 362 | #define _curl_is_ptr(expr, type) \ 363 | (_curl_is_NULL(expr) || \ 364 | __builtin_types_compatible_p(__typeof__(expr), type *) || \ 365 | __builtin_types_compatible_p(__typeof__(expr), const type *)) 366 | 367 | /* evaluates to true if expr is one of type[], type*, NULL or const type* */ 368 | #define _curl_is_arr(expr, type) \ 369 | (_curl_is_ptr((expr), type) || \ 370 | __builtin_types_compatible_p(__typeof__(expr), type [])) 371 | 372 | /* evaluates to true if expr is a string */ 373 | #define _curl_is_string(expr) \ 374 | (_curl_is_arr((expr), char) || \ 375 | _curl_is_arr((expr), signed char) || \ 376 | _curl_is_arr((expr), unsigned char)) 377 | 378 | /* evaluates to true if expr is a long (no matter the signedness) 379 | * XXX: for now, int is also accepted (and therefore short and char, which 380 | * are promoted to int when passed to a variadic function) */ 381 | #define _curl_is_long(expr) \ 382 | (__builtin_types_compatible_p(__typeof__(expr), long) || \ 383 | __builtin_types_compatible_p(__typeof__(expr), signed long) || \ 384 | __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ 385 | __builtin_types_compatible_p(__typeof__(expr), int) || \ 386 | __builtin_types_compatible_p(__typeof__(expr), signed int) || \ 387 | __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ 388 | __builtin_types_compatible_p(__typeof__(expr), short) || \ 389 | __builtin_types_compatible_p(__typeof__(expr), signed short) || \ 390 | __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ 391 | __builtin_types_compatible_p(__typeof__(expr), char) || \ 392 | __builtin_types_compatible_p(__typeof__(expr), signed char) || \ 393 | __builtin_types_compatible_p(__typeof__(expr), unsigned char)) 394 | 395 | /* evaluates to true if expr is of type curl_off_t */ 396 | #define _curl_is_off_t(expr) \ 397 | (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) 398 | 399 | /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ 400 | /* XXX: also check size of an char[] array? */ 401 | #define _curl_is_error_buffer(expr) \ 402 | (_curl_is_NULL(expr) || \ 403 | __builtin_types_compatible_p(__typeof__(expr), char *) || \ 404 | __builtin_types_compatible_p(__typeof__(expr), char[])) 405 | 406 | /* evaluates to true if expr is of type (const) void* or (const) FILE* */ 407 | #if 0 408 | #define _curl_is_cb_data(expr) \ 409 | (_curl_is_ptr((expr), void) || \ 410 | _curl_is_ptr((expr), FILE)) 411 | #else /* be less strict */ 412 | #define _curl_is_cb_data(expr) \ 413 | _curl_is_any_ptr(expr) 414 | #endif 415 | 416 | /* evaluates to true if expr is of type FILE* */ 417 | #define _curl_is_FILE(expr) \ 418 | (__builtin_types_compatible_p(__typeof__(expr), FILE *)) 419 | 420 | /* evaluates to true if expr can be passed as POST data (void* or char*) */ 421 | #define _curl_is_postfields(expr) \ 422 | (_curl_is_ptr((expr), void) || \ 423 | _curl_is_arr((expr), char)) 424 | 425 | /* FIXME: the whole callback checking is messy... 426 | * The idea is to tolerate char vs. void and const vs. not const 427 | * pointers in arguments at least 428 | */ 429 | /* helper: __builtin_types_compatible_p distinguishes between functions and 430 | * function pointers, hide it */ 431 | #define _curl_callback_compatible(func, type) \ 432 | (__builtin_types_compatible_p(__typeof__(func), type) || \ 433 | __builtin_types_compatible_p(__typeof__(func), type*)) 434 | 435 | /* evaluates to true if expr is of type curl_read_callback or "similar" */ 436 | #define _curl_is_read_cb(expr) \ 437 | (_curl_is_NULL(expr) || \ 438 | __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \ 439 | __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \ 440 | _curl_callback_compatible((expr), _curl_read_callback1) || \ 441 | _curl_callback_compatible((expr), _curl_read_callback2) || \ 442 | _curl_callback_compatible((expr), _curl_read_callback3) || \ 443 | _curl_callback_compatible((expr), _curl_read_callback4) || \ 444 | _curl_callback_compatible((expr), _curl_read_callback5) || \ 445 | _curl_callback_compatible((expr), _curl_read_callback6)) 446 | typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*); 447 | typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*); 448 | typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*); 449 | typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*); 450 | typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*); 451 | typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*); 452 | 453 | /* evaluates to true if expr is of type curl_write_callback or "similar" */ 454 | #define _curl_is_write_cb(expr) \ 455 | (_curl_is_read_cb(expr) || \ 456 | __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \ 457 | __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \ 458 | _curl_callback_compatible((expr), _curl_write_callback1) || \ 459 | _curl_callback_compatible((expr), _curl_write_callback2) || \ 460 | _curl_callback_compatible((expr), _curl_write_callback3) || \ 461 | _curl_callback_compatible((expr), _curl_write_callback4) || \ 462 | _curl_callback_compatible((expr), _curl_write_callback5) || \ 463 | _curl_callback_compatible((expr), _curl_write_callback6)) 464 | typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*); 465 | typedef size_t (_curl_write_callback2)(const char *, size_t, size_t, 466 | const void*); 467 | typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*); 468 | typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*); 469 | typedef size_t (_curl_write_callback5)(const void *, size_t, size_t, 470 | const void*); 471 | typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*); 472 | 473 | /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ 474 | #define _curl_is_ioctl_cb(expr) \ 475 | (_curl_is_NULL(expr) || \ 476 | __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \ 477 | _curl_callback_compatible((expr), _curl_ioctl_callback1) || \ 478 | _curl_callback_compatible((expr), _curl_ioctl_callback2) || \ 479 | _curl_callback_compatible((expr), _curl_ioctl_callback3) || \ 480 | _curl_callback_compatible((expr), _curl_ioctl_callback4)) 481 | typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*); 482 | typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*); 483 | typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*); 484 | typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*); 485 | 486 | /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ 487 | #define _curl_is_sockopt_cb(expr) \ 488 | (_curl_is_NULL(expr) || \ 489 | __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \ 490 | _curl_callback_compatible((expr), _curl_sockopt_callback1) || \ 491 | _curl_callback_compatible((expr), _curl_sockopt_callback2)) 492 | typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); 493 | typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, 494 | curlsocktype); 495 | 496 | /* evaluates to true if expr is of type curl_opensocket_callback or 497 | "similar" */ 498 | #define _curl_is_opensocket_cb(expr) \ 499 | (_curl_is_NULL(expr) || \ 500 | __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ 501 | _curl_callback_compatible((expr), _curl_opensocket_callback1) || \ 502 | _curl_callback_compatible((expr), _curl_opensocket_callback2) || \ 503 | _curl_callback_compatible((expr), _curl_opensocket_callback3) || \ 504 | _curl_callback_compatible((expr), _curl_opensocket_callback4)) 505 | typedef curl_socket_t (_curl_opensocket_callback1) 506 | (void *, curlsocktype, struct curl_sockaddr *); 507 | typedef curl_socket_t (_curl_opensocket_callback2) 508 | (void *, curlsocktype, const struct curl_sockaddr *); 509 | typedef curl_socket_t (_curl_opensocket_callback3) 510 | (const void *, curlsocktype, struct curl_sockaddr *); 511 | typedef curl_socket_t (_curl_opensocket_callback4) 512 | (const void *, curlsocktype, const struct curl_sockaddr *); 513 | 514 | /* evaluates to true if expr is of type curl_progress_callback or "similar" */ 515 | #define _curl_is_progress_cb(expr) \ 516 | (_curl_is_NULL(expr) || \ 517 | __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \ 518 | _curl_callback_compatible((expr), _curl_progress_callback1) || \ 519 | _curl_callback_compatible((expr), _curl_progress_callback2)) 520 | typedef int (_curl_progress_callback1)(void *, 521 | double, double, double, double); 522 | typedef int (_curl_progress_callback2)(const void *, 523 | double, double, double, double); 524 | 525 | /* evaluates to true if expr is of type curl_debug_callback or "similar" */ 526 | #define _curl_is_debug_cb(expr) \ 527 | (_curl_is_NULL(expr) || \ 528 | __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \ 529 | _curl_callback_compatible((expr), _curl_debug_callback1) || \ 530 | _curl_callback_compatible((expr), _curl_debug_callback2) || \ 531 | _curl_callback_compatible((expr), _curl_debug_callback3) || \ 532 | _curl_callback_compatible((expr), _curl_debug_callback4) || \ 533 | _curl_callback_compatible((expr), _curl_debug_callback5) || \ 534 | _curl_callback_compatible((expr), _curl_debug_callback6) || \ 535 | _curl_callback_compatible((expr), _curl_debug_callback7) || \ 536 | _curl_callback_compatible((expr), _curl_debug_callback8)) 537 | typedef int (_curl_debug_callback1) (CURL *, 538 | curl_infotype, char *, size_t, void *); 539 | typedef int (_curl_debug_callback2) (CURL *, 540 | curl_infotype, char *, size_t, const void *); 541 | typedef int (_curl_debug_callback3) (CURL *, 542 | curl_infotype, const char *, size_t, void *); 543 | typedef int (_curl_debug_callback4) (CURL *, 544 | curl_infotype, const char *, size_t, const void *); 545 | typedef int (_curl_debug_callback5) (CURL *, 546 | curl_infotype, unsigned char *, size_t, void *); 547 | typedef int (_curl_debug_callback6) (CURL *, 548 | curl_infotype, unsigned char *, size_t, const void *); 549 | typedef int (_curl_debug_callback7) (CURL *, 550 | curl_infotype, const unsigned char *, size_t, void *); 551 | typedef int (_curl_debug_callback8) (CURL *, 552 | curl_infotype, const unsigned char *, size_t, const void *); 553 | 554 | /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ 555 | /* this is getting even messier... */ 556 | #define _curl_is_ssl_ctx_cb(expr) \ 557 | (_curl_is_NULL(expr) || \ 558 | __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \ 559 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \ 560 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \ 561 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \ 562 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \ 563 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \ 564 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \ 565 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \ 566 | _curl_callback_compatible((expr), _curl_ssl_ctx_callback8)) 567 | typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *); 568 | typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *); 569 | typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *); 570 | typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *); 571 | #ifdef HEADER_SSL_H 572 | /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX 573 | * this will of course break if we're included before OpenSSL headers... 574 | */ 575 | typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); 576 | typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); 577 | typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); 578 | typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, 579 | const void *); 580 | #else 581 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; 582 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; 583 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; 584 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; 585 | #endif 586 | 587 | /* evaluates to true if expr is of type curl_conv_callback or "similar" */ 588 | #define _curl_is_conv_cb(expr) \ 589 | (_curl_is_NULL(expr) || \ 590 | __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \ 591 | _curl_callback_compatible((expr), _curl_conv_callback1) || \ 592 | _curl_callback_compatible((expr), _curl_conv_callback2) || \ 593 | _curl_callback_compatible((expr), _curl_conv_callback3) || \ 594 | _curl_callback_compatible((expr), _curl_conv_callback4)) 595 | typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); 596 | typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); 597 | typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); 598 | typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); 599 | 600 | /* evaluates to true if expr is of type curl_seek_callback or "similar" */ 601 | #define _curl_is_seek_cb(expr) \ 602 | (_curl_is_NULL(expr) || \ 603 | __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \ 604 | _curl_callback_compatible((expr), _curl_seek_callback1) || \ 605 | _curl_callback_compatible((expr), _curl_seek_callback2)) 606 | typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); 607 | typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); 608 | 609 | 610 | #endif /* __CURL_TYPECHECK_GCC_H */ 611 | --------------------------------------------------------------------------------