LosaDev source snapshot 2019
This commit is contained in:
commit
c198676e97
20588 files changed
+8812878
No files matched your search
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LS_RestAPI", "LS_RestAPI.vcxproj", "{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0C0B2FFF-5235-4083-8962-B4E68A3C7C93}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>LS_RestAPI</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>../lib</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>$(ProjectName)D</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>../lib</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>../lib/libcurld.lib</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>../lib/libcurl.lib</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ioRestAPI.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ioRestAPI.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ioRestAPI.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ioRestAPI.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,35 @@
|
||||
========================================================================
|
||||
정적 라이브러리 : LS_RestAPI 프로젝트 개요
|
||||
========================================================================
|
||||
|
||||
응용 프로그램 마법사에서 이 LS_RestAPI 라이브러리 프로젝트를 만들었습니다.
|
||||
|
||||
LS_RestAPI 응용 프로그램을 구성하는 각 파일에 대한
|
||||
요약 설명이 포함되어 있습니다.
|
||||
|
||||
|
||||
LS_RestAPI.vcxproj
|
||||
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
|
||||
파일을 생성한 Visual C++ 버전에 대한 정보와 응용 프로그램 마법사를 사용하여 선택한 플랫폼,
|
||||
구성 및 프로젝트 기능에 대한 정보가 포함되어 있습니다.
|
||||
|
||||
LS_RestAPI.vcxproj.filters
|
||||
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 필터 파일입니다.
|
||||
이 파일에는 프로젝트의 파일과 필터 간의 연결 정보가 들어 있습니다.
|
||||
이러한 연결은 특정 노드에서 유사한 확장명으로 그룹화된 파일을 표시하기 위해 IDE에서
|
||||
사용됩니다. 예를 들어 ".cpp" 파일은 "소스 파일" 필터와 연결되어 있습니다.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
이 파일은 미리 컴파일된 헤더(PCH) 파일 LS_RestAPI.pch와
|
||||
미리 컴파일된 형식(PCT) 파일 StdAfx.obj를 빌드하는 데 사용됩니다.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
기타 참고:
|
||||
|
||||
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
|
||||
소스 코드 부분을 나타냅니다.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,187 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ioRestAPI.h"
|
||||
#include "libcurl/curl.h"
|
||||
#include <vector>
|
||||
|
||||
#define STR_MAX 4096
|
||||
#define HTTP "http"
|
||||
#define DEFAULT_TIMEOUT 7000
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
void Trim(std::string& str)
|
||||
{
|
||||
std::string::size_type pos = str.find_last_not_of(' ');
|
||||
|
||||
if(pos != std::string::npos) {
|
||||
str.erase(pos + 1);
|
||||
pos = str.find_first_not_of(' ');
|
||||
if(pos != std::string::npos) str.erase(0, pos);
|
||||
}
|
||||
|
||||
else str.erase(str.begin(), str.end());
|
||||
}
|
||||
|
||||
extern void Tokenize( const std::string str, std::vector<std::string>& tokens, const std::string delimiters )
|
||||
{
|
||||
tokens.clear();
|
||||
|
||||
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||
|
||||
while (std::string::npos != pos || std::string::npos != lastPos)
|
||||
{
|
||||
std::string temp = str.substr(lastPos, pos - lastPos);
|
||||
|
||||
Trim(temp);
|
||||
tokens.push_back(temp);
|
||||
|
||||
lastPos = str.find_first_not_of(delimiters, pos);
|
||||
pos = str.find_first_of(delimiters, lastPos);
|
||||
}
|
||||
}
|
||||
|
||||
ioRestAPI::ioRestAPI(void)
|
||||
{
|
||||
InitData();
|
||||
|
||||
curl_global_init(CURL_GLOBAL_SSL);
|
||||
}
|
||||
|
||||
ioRestAPI::~ioRestAPI(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
void ioRestAPI::InitData()
|
||||
{
|
||||
m_szURL.clear();
|
||||
m_vCustomHeader.clear();
|
||||
m_szPostParam.clear();
|
||||
}
|
||||
|
||||
size_t ioRestAPI::write_data( void* ptr, size_t size, size_t nmemb, std::string* stream )
|
||||
{
|
||||
if(stream || size*nmemb < STR_MAX)
|
||||
{
|
||||
stream->append((char*)ptr, 0, size*nmemb);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
return size*nmemb;
|
||||
}
|
||||
|
||||
int ioRestAPI::SetURL( char* szURL )
|
||||
{
|
||||
if( CheckSize(strlen(szURL), STR_MAX) )
|
||||
{
|
||||
m_szURL = szURL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL ioRestAPI::AddCustomHeader( char* szCustomHeader )
|
||||
{
|
||||
if( CheckSize(strlen(szCustomHeader), STR_MAX) )
|
||||
{
|
||||
std::string szTemp = szCustomHeader;
|
||||
m_vCustomHeader.push_back(szTemp);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ioRestAPI::SetPostParam( char* szPostParam )
|
||||
{
|
||||
if( CheckSize(strlen(szPostParam), STR_MAX) )
|
||||
{
|
||||
m_szPostParam = szPostParam;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int ioRestAPI::Perfrom(std::string& szResultData, std::string& szErrCode)
|
||||
{
|
||||
int iReturnCode = 0;
|
||||
|
||||
CURL* curl_handle = NULL;
|
||||
CURLcode resCode = CURL_LAST;
|
||||
int iRespCode = 0;
|
||||
curl_slist* customHeaders = NULL;
|
||||
|
||||
curl_handle = curl_easy_init();
|
||||
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, m_szURL.c_str());
|
||||
|
||||
if(CheckHTTPS(m_szURL) == TRUE)
|
||||
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
|
||||
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
|
||||
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &szResultData);
|
||||
|
||||
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT_MS, DEFAULT_TIMEOUT);
|
||||
|
||||
if(!m_vCustomHeader.empty())
|
||||
{
|
||||
for(BYTE i=0; i<m_vCustomHeader.size(); i++)
|
||||
{
|
||||
customHeaders = curl_slist_append(customHeaders, m_vCustomHeader[i].c_str());
|
||||
}
|
||||
}
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, customHeaders) ;
|
||||
|
||||
if(!m_szPostParam.empty())
|
||||
{
|
||||
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, m_szPostParam.c_str());
|
||||
}
|
||||
|
||||
|
||||
resCode = curl_easy_perform(curl_handle);
|
||||
|
||||
if(resCode == CURLE_OK)
|
||||
{
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &iRespCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrCode = curl_easy_strerror(resCode);
|
||||
iReturnCode = -1;
|
||||
}
|
||||
|
||||
curl_slist_free_all(customHeaders);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
InitData();
|
||||
|
||||
return iReturnCode;
|
||||
}
|
||||
|
||||
BOOL ioRestAPI::CheckSize( DWORD dwInputSzie, DWORD dwLimit )
|
||||
{
|
||||
if(dwInputSzie > dwLimit)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ioRestAPI::CheckHTTPS( std::string& szURL )
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
|
||||
Tokenize(szURL, tokens, ":");
|
||||
|
||||
if(tokens.empty())
|
||||
return FALSE;
|
||||
|
||||
if(strcmp(HTTP, tokens[0].c_str()) == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <WTypes.h>
|
||||
|
||||
class ioRestAPI
|
||||
{
|
||||
public:
|
||||
ioRestAPI(void);
|
||||
virtual ~ioRestAPI(void);
|
||||
|
||||
public:
|
||||
static size_t write_data(void* ptr, size_t size, size_t nmemb, std::string* stream);
|
||||
|
||||
protected:
|
||||
void InitData();
|
||||
|
||||
public:
|
||||
int SetURL(char* szURL); //return 1==http 2==https -1==error
|
||||
BOOL AddCustomHeader(char* szCustomHeader);
|
||||
BOOL SetPostParam(char* szPostParam);
|
||||
|
||||
public:
|
||||
int Perfrom(std::string& szResultData, std::string& szErrCode);//return -1 is error
|
||||
|
||||
protected:
|
||||
BOOL CheckSize(DWORD dwInputSzie, DWORD dwLimit);
|
||||
BOOL CheckHTTPS(std::string& szURL);
|
||||
|
||||
protected:
|
||||
std::string m_szURL;
|
||||
std::vector<std::string> m_vCustomHeader;
|
||||
std::string m_szPostParam;
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
|
||||
// LS_RestAPI.pch는 미리 컴파일된 헤더가 됩니다.
|
||||
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 필요한 추가 헤더는
|
||||
// 이 파일이 아닌 STDAFX.H에서 참조합니다.
|
||||
@@ -0,0 +1,14 @@
|
||||
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
|
||||
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
|
||||
// 들어 있는 포함 파일입니다.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
|
||||
|
||||
|
||||
|
||||
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// SDKDDKVer.h를 포함하면 최고 수준의 가용성을 가진 Windows 플랫폼이 정의됩니다.
|
||||
|
||||
// 이전 Windows 플랫폼에 대해 응용 프로그램을 빌드하려는 경우에는 SDKDDKVer.h를 포함하기 전에
|
||||
// WinSDKVer.h를 포함하고 _WIN32_WINNT 매크로를 지원하려는 플랫폼으로 설정하십시오.
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
Reference in new issue
Block a user